repo stringlengths 6 65 | file_url stringlengths 81 311 | file_path stringlengths 6 227 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:31:58 2026-01-04 20:25:31 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/errors.rs | src/errors.rs | //! # Application Error Handling
use axum::{
extract::rejection::JsonRejection,
http::{
header::{InvalidHeaderName, InvalidHeaderValue},
method::InvalidMethod,
StatusCode,
},
};
use lettre::{address::AddressError, transport::smtp};
use crate::{controller::ErrorDetail, depcheck, val... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/prelude.rs | src/prelude.rs | pub use async_trait::async_trait;
pub use axum::{
debug_handler,
extract::{Form, Multipart, Path, Query, State},
response::{IntoResponse, Response},
routing::{delete, get, head, options, patch, post, put, trace},
};
pub use axum_extra::extract::cookie;
pub use chrono::NaiveDateTime as DateTime;
pub use ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/lib.rs | src/lib.rs | #![allow(clippy::missing_const_for_fn)]
#![allow(clippy::module_name_repetitions)]
#![doc = include_str!("../README.md")]
pub use self::errors::Error;
mod banner;
pub mod bgworker;
mod depcheck;
pub mod initializers;
pub mod prelude;
pub mod data;
pub mod doctor;
#[cfg(feature = "with-db")]
pub mod db;
#[cfg(featur... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/environment.rs | src/environment.rs | //! Defines the application environment.
//! By given the environment you can also load the application configuration
//!
//! # Example:
//!
//! ```rust
//! use std::str::FromStr;
//! use loco_rs::environment::Environment;
//!
//! pub fn load(environment: &str) {
//! let environment = Environment::from_str(environment... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/banner.rs | src/banner.rs | use colored::Colorize;
use crate::boot::{BootResult, ServeParams};
pub const BANNER: &str = r"
▄ ▀
▀ ▄
▄ ▀ ▄ ▄ ▄▀
▄ ▀▄▄
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/logger.rs | src/logger.rs | //! initialization application logger.
use std::sync::OnceLock;
use serde::{Deserialize, Serialize};
use serde_variant::to_variant_name;
use tracing_appender::non_blocking::WorkerGuard;
use tracing_subscriber::{
fmt, fmt::MakeWriter, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer, Registry,
};
u... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/validation.rs | src/validation.rs | //! This module provides utility functions for handling validation errors for
//! structs. It useful if you want to validate model before insert to Database.
//!
//! # Example:
//!
//! In the following example you can see how you can validate a user model
//! ```rust,ignore
//! use loco_rs::prelude::*;
//! pub use myap... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cli.rs | src/cli.rs | //! command-line interface for running various tasks and commands
//! related to the application. It allows developers to interact with the
//! application via the command line.
//!
//! # Example
//!
//! ```rust,ignore
//! use myapp::app::App;
//! use loco_rs::cli;
//! use migration::Migrator;
//!
//! #[tokio::main]
//... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tera.rs | src/tera.rs | use tera::{Context, Tera};
use crate::Result;
pub fn render_string(tera_template: &str, locals: &serde_json::Value) -> Result<String> {
let text = Tera::one_off(tera_template, &Context::from_serialize(locals)?, false)?;
Ok(text)
}
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/schema.rs | src/schema.rs | use heck::ToSnakeCase;
use sea_orm::{
sea_query::{
Alias, ColumnDef, Expr, Index, IntoIden, PgInterval, Table, TableAlterStatement,
TableCreateStatement, TableForeignKey,
},
ColumnType, ConnectionTrait, DbErr, ForeignKeyAction,
};
pub use sea_orm_migration::schema::*;
use sea_orm_migration::... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/depcheck.rs | src/depcheck.rs | use std::collections::HashMap;
use semver::{Version, VersionReq};
use thiserror::Error;
use crate::cargo_config::CargoConfig;
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd)]
pub enum VersionStatus {
NotFound,
Invalid {
version: String,
min_version: String,
},
Ok(String),
}
#[derive(... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/hash.rs | src/hash.rs | use crate::{Error, Result};
use argon2::{
password_hash::{rand_core::OsRng, SaltString},
Argon2, Params, PasswordHash, PasswordHasher, PasswordVerifier, Version,
};
use rand::{distr::Alphanumeric, rng, Rng};
/// Hashes a plain text password and returns the hashed result.
///
/// # Errors
///
/// Return [`argon... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/doctor.rs | src/doctor.rs | //! Doctor module for health checks and diagnostics.
//!
//! This module provides health checks for various components of a Loco application.
//!
//! # Initializer Health Checks
//!
//! Initializers can now provide their own health checks by implementing the `check` method
//! on the `Initializer` trait. This allows ea... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/task.rs | src/task.rs | //! # Task Management Module
//!
//! This module defines the task management framework used to manage and execute
//! tasks in a web server application.
use std::collections::BTreeMap;
use async_trait::async_trait;
use crate::{app::AppContext, errors::Error, Result};
/// Struct representing a collection of task argu... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/boot.rs | src/boot.rs | //! # Application Bootstrapping and Logic
//! This module contains functions and structures for bootstrapping and running
//! your application.
use std::{
env,
path::{Path, PathBuf},
sync::Arc,
};
use axum::Router;
#[cfg(feature = "with-db")]
use sea_orm_migration::MigratorTrait;
use tokio::{select, signal... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/env_vars.rs | src/env_vars.rs | //! This module contains utility functions and constants for working with
//! environment variables in the application. It centralizes the logic for
//! fetching environment variables, ensuring that keys are easily accessible
//! from a single location in the codebase.
#[cfg(feature = "with-db")]
/// The key for `Post... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/data.rs | src/data.rs | use std::{env, path::Path};
use serde::de::DeserializeOwned;
use crate::{env_vars, Error, Result};
const DEFAULT_DATA_FOLDER: &str = "data";
fn data_folder() -> String {
env::var(env_vars::LOCO_DATA_FOLDER_ENV).unwrap_or_else(|_| DEFAULT_DATA_FOLDER.to_string())
}
/// Load a data JSON file synchronously
///
///... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cargo_config.rs | src/cargo_config.rs | //! Cargo.toml configuration reader module
//!
//! This module provides functionality to read and parse Cargo.toml files,
//! with specific support for accessing database entity configuration
//! under the `[package.metadata.db.entity]` section.
use crate::errors::Error;
use crate::Result as AppResult;
use std::path::... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/scheduler.rs | src/scheduler.rs | //! # Scheduler Module
//! TBD
use std::{
collections::HashMap,
fmt, io,
path::{Path, PathBuf},
sync::OnceLock,
time::{Duration, Instant},
};
use regex::Regex;
use serde::{Deserialize, Serialize};
use tokio_cron_scheduler::{JobScheduler, JobSchedulerError};
use uuid::Uuid;
use crate::{app::Hooks,... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/app_routes.rs | src/controller/app_routes.rs | //! This module defines the [`AppRoutes`] struct that is responsible for
//! configuring routes in an Axum application. It allows you to define route
//! prefixes, add routes, and configure middlewares for the application.
use std::{fmt, sync::OnceLock};
use axum::Router as AXRouter;
use regex::Regex;
use crate::{
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/monitoring.rs | src/controller/monitoring.rs | //! This module contains a base routes related to readiness checks and status
//! reporting. These routes are commonly used to monitor the readiness of the
//! application and its dependencies.
use super::{format, routes::Routes};
#[cfg(any(feature = "cache_inmem", feature = "cache_redis"))]
use crate::config;
use cra... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/describe.rs | src/controller/describe.rs | use std::sync::OnceLock;
use axum::{http, routing::MethodRouter};
use regex::Regex;
use crate::app::AppContext;
static DESCRIBE_METHOD_ACTION: OnceLock<Regex> = OnceLock::new();
fn get_describe_method_action() -> &'static Regex {
DESCRIBE_METHOD_ACTION.get_or_init(|| Regex::new(r"\b(\w+):\s*(BoxedHandler|Route)... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/mod.rs | src/controller/mod.rs | //! Manage web server routing
//!
//! # Example
//!
//! This example you can adding custom routes into your application by
//! implementing routes trait from [`crate::app::Hooks`] and adding your
//! endpoints to your application
//!
//! ```rust
//! use async_trait::async_trait;
//! use loco_rs::{
//! app::{AppConte... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/format.rs | src/controller/format.rs | //! This module contains utility functions for generating HTTP responses that
//! are commonly used in web applications. These functions simplify the process
//! of creating responses with various data types.
//!
//! # Example:
//!
//! This example illustrates how to construct a JSON-formatted response using a
//! Rust... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/backtrace.rs | src/controller/backtrace.rs | use std::sync::OnceLock;
use regex::Regex;
use crate::{Error, Result};
static NAME_BLOCKLIST: OnceLock<Vec<Regex>> = OnceLock::new();
static FILE_BLOCKLIST: OnceLock<Vec<Regex>> = OnceLock::new();
fn get_name_blocklist() -> &'static Vec<Regex> {
NAME_BLOCKLIST.get_or_init(|| {
[
"^___rust_tr... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/routes.rs | src/controller/routes.rs | use std::convert::Infallible;
use axum::{extract::Request, response::IntoResponse, routing::Route};
use tower::{Layer, Service};
use super::describe;
use crate::app::AppContext;
#[derive(Clone, Default, Debug)]
pub struct Routes {
pub prefix: Option<String>,
pub handlers: Vec<Handler>,
// pub version: Opt... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/extractor/shared_store.rs | src/controller/extractor/shared_store.rs | use crate::{app::AppContext, Error};
use axum::{extract::FromRequestParts, http::request::Parts};
use std::any::Any;
/// An extractor that streamlines the process of getting static Data from the `DiContainer`.
pub struct SharedStore<T>(pub T);
impl<T> FromRequestParts<AppContext> for SharedStore<T>
where
T: Any +... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/extractor/auth.rs | src/controller/extractor/auth.rs | //! Axum middleware for validating token header
//!
//! # Example:
//!
//! ```
//! use loco_rs::prelude::*;
//! use serde::Serialize;
//! use axum::extract::State;
//! use loco_rs::controller::extractor::auth;
//!
//! #[derive(Serialize)]
//! pub struct TestResponse {
//! pub pid: String,
//! }
//!
//! async fn cur... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/extractor/mod.rs | src/controller/extractor/mod.rs | #[cfg(feature = "auth_jwt")]
pub mod auth;
pub mod shared_store;
pub mod validate;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/extractor/validate.rs | src/controller/extractor/validate.rs | use crate::validation::ValidatorTrait;
use axum::extract::{Form, FromRequest, Json, Query, Request};
use serde::de::DeserializeOwned;
use crate::Error;
/// Axum middleware for validating JSON request bodies
///
/// This module provides extractors for validating JSON request bodies, form
/// data, path parameters, and... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/timeout.rs | src/controller/middleware/timeout.rs | //! Timeout Request Middleware.
//!
//! This middleware applies a timeout to requests processed by the application.
//! The timeout duration is configurable and defined via the
//! [`TimeoutRequestMiddleware`] configuration. The middleware ensures that
//! requests do not run beyond the specified timeout period, improv... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/limit_payload.rs | src/controller/middleware/limit_payload.rs | //! Limit Payload Middleware
//!
//! This middleware restricts the maximum allowed size for HTTP request
//! payloads. It is configurable based on the [`LimitPayloadMiddleware`]
//! settings in the application's middleware configuration. The middleware sets
//! a limit on the request body size using Axum's `DefaultBody... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/static_assets.rs | src/controller/middleware/static_assets.rs | //! Static Assets Middleware.
//!
//! This middleware serves static files (e.g., images, CSS, JS) from a specified
//! folder to the client. It also allows configuration of a fallback file to
//! serve in case a requested file is not found. Additionally, it can serve
//! precompressed files if enabled via the configura... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/logger.rs | src/controller/middleware/logger.rs | //! Logger Middleware
//!
//! This middleware provides logging functionality for HTTP requests. It uses
//! `TraceLayer` to log detailed information about each request, such as the
//! HTTP method, URI, version, user agent, and an associated request ID.
//! Additionally, it integrates the application's runtime environm... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/request_id.rs | src/controller/middleware/request_id.rs | //! Middleware to generate or ensure a unique request ID for every request.
//!
//! The request ID is stored in the `x-request-id` header, and it is either
//! generated or sanitized if already present in the request.
//!
//! This can be useful for tracking requests across services, logging, and
//! debugging.
use axu... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/static_assets_embedded.rs | src/controller/middleware/static_assets_embedded.rs | //! Static Assets Embedded Middleware.
//!
//! This middleware serves static files (e.g., images, CSS, JS) from embedded
//! assets built into the binary. It also provides a fallback file to serve in
//! case a requested file is not found.
//!
//! This is particularly useful for distributing single-binary applications
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/remote_ip.rs | src/controller/middleware/remote_ip.rs | //! Remote IP Middleware for inferring the client's IP address based on the
//! `X-Forwarded-For` header.
//!
//! This middleware is useful when running behind proxies or load balancers that
//! add the `X-Forwarded-For` header, which includes the original client IP
//! address.
//!
//! The middleware provides a mechan... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/cors.rs | src/controller/middleware/cors.rs | //! Configurable and Flexible CORS Middleware
//!
//! This middleware enables Cross-Origin Resource Sharing (CORS) by allowing
//! configurable origins, methods, and headers in HTTP requests. It can be
//! tailored to fit various application requirements, supporting permissive CORS
//! or specific rules as defined in t... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/catch_panic.rs | src/controller/middleware/catch_panic.rs | //! Catch Panic Middleware for Axum
//!
//! This middleware catches panics that occur during request handling in the
//! application. When a panic occurs, it logs the error and returns an
//! internal server error response. This middleware helps ensure that the
//! application can gracefully handle unexpected errors wi... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/mod.rs | src/controller/middleware/mod.rs | //! Base Middleware for Loco Application
//!
//! This module defines the various middleware components that Loco provides.
//! Each middleware is responsible for handling different aspects of request
//! processing, such as authentication, logging, CORS, compression, and error
//! handling. The middleware can be easily... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/format.rs | src/controller/middleware/format.rs | //! Detect a content type and format and responds accordingly
use axum::{
extract::FromRequestParts,
http::{
header::{HeaderMap, ACCEPT, CONTENT_TYPE},
request::Parts,
},
};
use serde::{Deserialize, Serialize};
use crate::Error;
#[derive(Debug, Deserialize, Serialize)]
pub struct Format(pu... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/secure_headers.rs | src/controller/middleware/secure_headers.rs | //! Sets secure headers for your backend to promote security-by-default.
//!
//! This middleware applies secure HTTP headers, providing pre-defined presets
//! (e.g., "github") and the ability to override or define custom headers.
use std::{
collections::{BTreeMap, HashMap},
sync::OnceLock,
task::{Context,... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/compression.rs | src/controller/middleware/compression.rs | //! Compression Middleware for Axum
//!
//! This middleware applies compression to HTTP responses to reduce the size of
//! the data being transmitted. This can improve performance by decreasing load
//! times and reducing bandwidth usage. The middleware configuration allows for
//! enabling or disabling compression ba... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/etag.rs | src/controller/middleware/etag.rs | //! `ETag` Middleware for Caching Requests
//!
//! This middleware implements the [ETag](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag)
//! HTTP header for caching responses in Axum. `ETags` are used to validate
//! cache entries by comparing a client's stored `ETag` with the one generated
//! by the s... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/fallback.rs | src/controller/middleware/fallback.rs | //! Fallback Middleware
//!
//! This middleware handles fallback logic for the application when routes do
//! not match. It serves a file, a custom not-found message, or a default HTML
//! fallback page based on the configuration.
use axum::{http::StatusCode, response::Html, Router as AXRouter};
use serde::{Deserializ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/powered_by.rs | src/controller/middleware/powered_by.rs | //! Powered-By Middleware
//!
//! This middleware injects an HTTP header `X-Powered-By` into the response
//! headers of every request handled by the application. The header identifies
//! the software or technology stack powering the application. It supports a
//! custom identifier string or defaults to "loco.rs" if n... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/middleware/_archive/content_etag.rs | src/controller/middleware/_archive/content_etag.rs | use std::{
pin::Pin,
task::{Context, Poll},
};
use axum::{
body::{to_bytes, Body, Bytes},
extract::Request,
response::Response,
BoxError,
};
use futures_util::Future;
use hyper::header::{ETAG, IF_NONE_MATCH};
use sha2::{Digest, Sha256};
use tower::{Layer, Service}; // Corrected import
#[derive... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/engine.rs | src/controller/views/engine.rs | use std::path::{Path, PathBuf};
use super::tera_builtins;
use crate::{controller::views::ViewRenderer, Error, Result};
use serde::Serialize;
#[cfg(debug_assertions)]
use notify::{
event::{EventKind, ModifyKind},
Event, RecursiveMode, Watcher,
};
pub static DEFAULT_ASSET_FOLDER: &str = "assets";
#[cfg(debug_... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/engine_embedded.rs | src/controller/views/engine_embedded.rs | use super::tera_builtins;
use crate::{controller::views::ViewRenderer, Result};
use serde::Serialize;
use std::collections::BTreeMap;
pub static DEFAULT_ASSET_FOLDER: &str = "assets";
// Include the generated templates at the module level
include!(concat!(
env!("OUT_DIR"),
"/generated_code/view_templates.rs"
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/mod.rs | src/controller/views/mod.rs | // Choose the correct engine implementation based on the feature flag
#[cfg(feature = "embedded_assets")]
pub mod engine_embedded;
#[cfg(feature = "embedded_assets")]
pub use engine_embedded as engines;
#[cfg(not(feature = "embedded_assets"))]
pub mod engine;
#[cfg(not(feature = "embedded_assets"))]
pub use engine as ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/pagination.rs | src/controller/views/pagination.rs | use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Pager<T> {
#[serde(rename(serialize = "results"))]
pub results: T,
#[serde(rename(serialize = "pagination"))]
pub info: PagerMeta,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct PagerMeta {
#[serde(ren... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/tera_builtins/mod.rs | src/controller/views/tera_builtins/mod.rs | pub mod filters;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/tera_builtins/filters/number.rs | src/controller/views/tera_builtins/filters/number.rs | #![allow(clippy::implicit_hasher)]
use std::collections::HashMap;
use byte_unit::Byte;
use serde_json::value::Value;
use tera::Result;
/// Helper function to add commas as thousands separators
fn separate_with_commas(num_str: &str) -> String {
if let Some((integer_part, decimal_part)) = num_str.split_once('.') {
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/controller/views/tera_builtins/filters/mod.rs | src/controller/views/tera_builtins/filters/mod.rs | pub mod number;
pub fn register_filters(tera: &mut tera::Tera) {
tera.register_filter("number_with_delimiter", number::number_with_delimiter);
tera.register_filter("number_to_human_size", number::number_to_human_size);
tera.register_filter("number_to_percentage", number::number_to_percentage);
}
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/initializers/extra_db.rs | src/initializers/extra_db.rs | use async_trait::async_trait;
use axum::{Extension, Router as AxumRouter};
use crate::{
app::{AppContext, Initializer},
db, Error, Result,
};
#[allow(clippy::module_name_repetitions)]
pub struct ExtraDbInitializer;
#[async_trait]
impl Initializer for ExtraDbInitializer {
fn name(&self) -> String {
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/initializers/mod.rs | src/initializers/mod.rs | #[cfg(feature = "with-db")]
pub mod extra_db;
#[cfg(feature = "with-db")]
pub mod multi_db;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/initializers/multi_db.rs | src/initializers/multi_db.rs | use async_trait::async_trait;
use axum::{Extension, Router as AxumRouter};
use crate::{
app::{AppContext, Initializer},
db, Error, Result,
};
#[allow(clippy::module_name_repetitions)]
pub struct MultiDbInitializer;
#[async_trait]
impl Initializer for MultiDbInitializer {
fn name(&self) -> String {
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/stream.rs | src/storage/stream.rs | use std::pin::Pin;
use std::task::{Context, Poll};
use bytes::Bytes;
use futures_util::{Stream, StreamExt};
use opendal::Reader;
/// A stream of bytes that abstracts over the underlying storage implementation.
/// This type ensures that `OpenDAL` types are not exposed in the public API.
pub struct BytesStream {
i... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/contents.rs | src/storage/contents.rs | use bytes::Bytes;
#[derive(Debug)]
pub struct Contents {
data: Bytes,
}
impl From<Bytes> for Contents {
/// Converts a `Vec<u8>` into a `Contents` instance.
///
/// # Returns
///
/// Returns a `Contents` instance with the provided byte data.
fn from(data: Bytes) -> Self {
Self { da... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/mod.rs | src/storage/mod.rs | //! # Storage Module
//!
//! This module defines a generic storage abstraction represented by the
//! [`Storage`] struct. It provides methods for performing common storage
//! operations such as upload, download, delete, rename, and copy.
//!
//! ## Storage Strategy
//!
//! The [`Storage`] struct is designed to work wi... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/gcp.rs | src/storage/drivers/gcp.rs | use opendal::{services::Gcs, Operator};
use super::StoreDriver;
use crate::storage::{drivers::opendal_adapter::OpendalAdapter, StorageResult};
/// Create new GCP storage.
///
/// # Examples
///```
/// use loco_rs::storage::drivers::gcp;
/// let gcp_driver = gcp::new("key", "credential_path");
/// ```
///
/// # Errors... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/aws.rs | src/storage/drivers/aws.rs | use opendal::{services::S3, Operator};
use super::{opendal_adapter::OpendalAdapter, StoreDriver};
use crate::storage::StorageResult;
/// A set of AWS security credentials
#[derive(Debug)]
pub struct Credential {
/// `AWS_ACCESS_KEY_ID`
pub key_id: String,
/// `AWS_SECRET_ACCESS_KEY`
pub secret_key: St... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/local.rs | src/storage/drivers/local.rs | use opendal::{services::Fs, Operator};
use super::StoreDriver;
use crate::storage::{drivers::opendal_adapter::OpendalAdapter, StorageResult};
/// Create new filesystem storage with no prefix
///
/// # Examples
///```
/// use loco_rs::storage::drivers::local;
/// let file_system_driver = local::new();
/// ```
///
/// ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/azure.rs | src/storage/drivers/azure.rs | use opendal::{services::Azblob, Operator};
use super::StoreDriver;
use crate::storage::{drivers::opendal_adapter::OpendalAdapter, StorageResult};
/// Create new Azure storage.
///
/// # Examples
///```
/// use loco_rs::storage::drivers::azure;
/// let azure_driver = azure::new("name", "account_name", "access_key", "e... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/mod.rs | src/storage/drivers/mod.rs | use std::path::Path;
use async_trait::async_trait;
use bytes::Bytes;
use opendal::Reader;
#[cfg(feature = "storage_aws_s3")]
pub mod aws;
#[cfg(feature = "storage_azure")]
pub mod azure;
#[cfg(feature = "storage_gcp")]
pub mod gcp;
pub mod local;
pub mod mem;
pub mod null;
pub mod opendal_adapter;
use super::{stream... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/null.rs | src/storage/drivers/null.rs | //! # Null Storage Driver
//!
//! The Null storage Driver is the default storage driver implemented when the
//! Loco framework is initialized. The primary purpose of this driver is to
//! simplify the user workflow by avoiding the need for feature flags or
//! optional storage driver configurations.
use std::path::Pat... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/mem.rs | src/storage/drivers/mem.rs | use opendal::{services::Memory, Operator};
use super::StoreDriver;
use crate::storage::drivers::opendal_adapter::OpendalAdapter;
/// Create new in-memory storage.
///
/// # Examples
///```
/// use loco_rs::storage::drivers::mem;
/// let mem_storage = mem::new();
/// ```
///
/// # Panics
///
/// Panics if the memory s... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/drivers/opendal_adapter.rs | src/storage/drivers/opendal_adapter.rs | use std::path::Path;
use async_trait::async_trait;
use bytes::Bytes;
use futures_util::{SinkExt, StreamExt};
use opendal::{layers::RetryLayer, Operator};
use super::{GetResponse, StoreDriver, UploadResponse};
use crate::storage::{stream::BytesStream, StorageError, StorageResult};
pub struct OpendalAdapter {
open... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/strategies/mirror.rs | src/storage/strategies/mirror.rs | //! # `MirrorStrategy` Implementation for Storage Strategies
//!
//! This module provides an implementation of the [`StorageStrategy`] for
//! the [`MirrorStrategy`]. The [`MirrorStrategy`] is designed to mirror storage
//! operations.
//!
//! ## Strategy Description per operation
//!
//! * `upload`/`delete`/`rename`/`... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/strategies/mod.rs | src/storage/strategies/mod.rs | pub mod backup;
pub mod mirror;
pub mod single;
use std::path::Path;
use bytes::Bytes;
use crate::storage::{stream::BytesStream, Storage, StorageResult};
#[async_trait::async_trait]
pub trait StorageStrategy: Sync + Send {
async fn upload(&self, storage: &Storage, path: &Path, content: &Bytes) -> StorageResult<... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/strategies/backup.rs | src/storage/strategies/backup.rs | //! # `BackupStrategy` Implementation for Storage Strategies
//!
//! This module provides an implementation of the [`StorageStrategy`] for
//! the [`BackupStrategy`]. The [`BackupStrategy`] is designed to mirror storage
//! operations.
//!
//! ## Strategy Description per operation
//!
//! * `upload`/`delete`/`rename`/`... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/storage/strategies/single.rs | src/storage/strategies/single.rs | //! # Single Storage Strategy Implementation
//!
//! This module provides an implementation of the [`StorageStrategy`] for a
//! single storage strategy.
use std::path::Path;
use bytes::Bytes;
use crate::storage::{strategies::StorageStrategy, Storage, StorageResult};
/// Represents a single storage strategy.
#[deriv... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/auth/jwt.rs | src/auth/jwt.rs | //! # JSON Web Token (JWT) and Password Hashing
//!
//! This module provides functionality for working with JSON Web Tokens (JWTs)
//! and password hashing.
use jsonwebtoken::{
decode, encode, errors::Result as JWTResult, get_current_timestamp, Algorithm, DecodingKey,
EncodingKey, Header, TokenData, Validation,... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/auth/mod.rs | src/auth/mod.rs | #[cfg(feature = "auth_jwt")]
pub mod jwt;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/mailer/template.rs | src/mailer/template.rs | //! This module defines a template rendering mechanism for generating email
//! content using Tera templates. It includes functions to read embedded
//! template files, a `Content` struct to hold email content, and a `Template`
//! struct to manage template rendering.
//!
//! # Example
//!
//! ```rust, ignore
//! use i... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/mailer/mod.rs | src/mailer/mod.rs | //! This module defines the email-related functionality, including the `Mailer`
//! trait and its implementation, `Email` structure, and the `MailerWorker` for
//! asynchronous email processing.
mod email_sender;
mod template;
use async_trait::async_trait;
pub use email_sender::EmailSender;
use include_dir::Dir;
use ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/mailer/email_sender.rs | src/mailer/email_sender.rs | //! This module defines an [`EmailSender`] responsible for sending emails using
//! either the SMTP protocol. It includes an asynchronous method `mail` for
//! sending emails with options like sender, recipient, subject, and content.
use lettre::{
message::{header, MultiPart},
transport::smtp::{authentication:... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cache/mod.rs | src/cache/mod.rs | //! # Cache Module
//!
//! This module provides a generic cache interface for various cache drivers.
pub mod drivers;
use std::{future::Future, time::Duration};
use serde::{de::DeserializeOwned, Serialize};
pub use self::drivers::CacheDriver;
use crate::config;
use crate::Result as LocoResult;
use std::sync::Arc;
/... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cache/drivers/inmem.rs | src/cache/drivers/inmem.rs | //! # In-Memory Cache Driver
//!
//! This module implements a cache driver using an in-memory cache.
use std::{
sync::Arc,
time::{Duration, Instant},
};
use async_trait::async_trait;
use moka::{sync::Cache, Expiry};
use super::CacheDriver;
use crate::cache::CacheResult;
use crate::config::InMemCacheConfig;
/... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cache/drivers/mod.rs | src/cache/drivers/mod.rs | //! # Cache Drivers Module
//!
//! This module defines traits and implementations for cache drivers.
use std::time::Duration;
use async_trait::async_trait;
use super::CacheResult;
#[cfg(feature = "cache_inmem")]
pub mod inmem;
pub mod null;
#[cfg(feature = "cache_redis")]
pub mod redis;
/// Trait representing a cac... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cache/drivers/null.rs | src/cache/drivers/null.rs | //! # Null Cache Driver
//!
//! The Null Cache Driver is the default cache driver implemented when the Loco
//! framework is initialized. The primary purpose of this driver is to simplify
//! the user workflow by avoiding the need for feature flags or optional cache
//! driver configurations.
use std::time::Duration;
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/cache/drivers/redis.rs | src/cache/drivers/redis.rs | //! # Redis Cache Driver
//!
//! This module implements a cache driver using Redis.
use std::time::Duration;
use async_trait::async_trait;
use bb8::Pool;
use bb8_redis::{
bb8,
redis::{cmd, AsyncCommands},
RedisConnectionManager,
};
use super::CacheDriver;
use crate::cache::{CacheError, CacheResult};
use c... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/model/mod.rs | src/model/mod.rs | //! # Model Error Handling
//!
//! Useful when using `sea_orm` and want to propagate errors
pub mod query;
use async_trait::async_trait;
use sea_orm::DatabaseConnection;
use crate::validation::ModelValidationErrors;
#[derive(thiserror::Error, Debug)]
#[allow(clippy::module_name_repetitions)]
pub enum ModelError {
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/model/query/mod.rs | src/model/query/mod.rs | mod dsl;
mod paginate;
pub use dsl::*;
pub use paginate::*;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/model/query/dsl/date_range.rs | src/model/query/dsl/date_range.rs | use chrono::NaiveDateTime;
use sea_orm::ColumnTrait;
use super::{with, ConditionBuilder};
#[derive(Debug)]
pub struct DateRangeBuilder<T: ColumnTrait> {
col: T,
condition_builder: ConditionBuilder,
from_date: Option<NaiveDateTime>,
to_date: Option<NaiveDateTime>,
}
impl<T: ColumnTrait> DateRangeBuild... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/model/query/dsl/mod.rs | src/model/query/dsl/mod.rs | use sea_orm::{
sea_query::{IntoCondition, Order},
ColumnTrait, Condition, Value,
};
use serde::{Deserialize, Serialize};
mod date_range;
// pub mod pagination;
#[derive(Debug)]
pub struct ConditionBuilder {
condition: Condition,
}
/// Enum representing sorting directions, with serialization and deseriali... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/model/query/paginate/mod.rs | src/model/query/paginate/mod.rs | use sea_orm::{prelude::*, Condition, DatabaseConnection, EntityTrait, QueryFilter, SelectorTrait};
use serde::{Deserialize, Serialize};
/// Set the default pagination page size.
const fn default_page_size() -> u64 {
25
}
/// Set the default pagination page.
const fn default_page() -> u64 {
1
}
/// Structure ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/bgworker/sqlt.rs | src/bgworker/sqlt.rs | /// `SQLite` based background job queue provider
use std::{
collections::HashMap, future::Future, panic::AssertUnwindSafe, pin::Pin, sync::Arc,
time::Duration,
};
use super::{BackgroundWorker, JobStatus, Queue};
use crate::{config::SqliteQueueConfig, Error, Result};
use chrono::{DateTime, Utc};
use futures_uti... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/bgworker/mod.rs | src/bgworker/mod.rs | use std::{
fs::File,
io::Write,
path::{Path, PathBuf},
sync::Arc,
};
use async_trait::async_trait;
#[cfg(feature = "cli")]
use clap::ValueEnum;
use serde::{Deserialize, Serialize};
use serde_variant::to_variant_name;
#[cfg(feature = "bg_pg")]
pub mod pg;
#[cfg(feature = "bg_redis")]
pub mod redis;
#[cf... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/bgworker/pg.rs | src/bgworker/pg.rs | /// Postgres based background job queue provider
use std::{
collections::HashMap, future::Future, panic::AssertUnwindSafe, pin::Pin, sync::Arc,
time::Duration,
};
use super::{BackgroundWorker, JobStatus, Queue};
use crate::{config::PostgresQueueConfig, Error, Result};
use chrono::{DateTime, Utc};
use futures_u... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/bgworker/redis.rs | src/bgworker/redis.rs | /// Redis based background job queue provider
use std::{
collections::HashMap, future::Future, panic::AssertUnwindSafe, pin::Pin, sync::Arc,
time::Duration,
};
use super::{BackgroundWorker, JobStatus, Queue};
use crate::{config::RedisQueueConfig, Error, Result};
use chrono::{DateTime, Utc};
use futures_util::F... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | true |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/db.rs | src/tests_cfg/db.rs | use std::path::Path;
use async_trait::async_trait;
use sea_orm::Statement;
pub use sea_orm_migration::prelude::*;
use crate::{
app::{AppContext, Hooks, Initializer},
bgworker::Queue,
boot::{create_app, BootResult, StartMode},
config::Config,
controller::AppRoutes,
environment::Environment,
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/config.rs | src/tests_cfg/config.rs | use std::collections::HashMap;
use crate::{
config::{self, Config},
controller::middleware,
logger, scheduler,
};
use tree_fs::{Tree, TreeBuilder};
#[must_use]
pub fn test_config() -> Config {
Config {
logger: config::Logger {
enable: false,
pretty_backtrace: true,
... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/app.rs | src/tests_cfg/app.rs | use crate::{
app::{AppContext, SharedStore},
cache,
environment::Environment,
storage::{self, Storage},
tests_cfg::config::test_config,
};
pub async fn get_app_context() -> AppContext {
// Always use in-memory cache for tests if feature is available, otherwise fall back to null
#[cfg(featur... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/mod.rs | src/tests_cfg/mod.rs | pub mod app;
pub mod config;
pub mod controllers;
#[cfg(feature = "with-db")]
pub mod db;
#[cfg(test)]
pub mod postgres;
#[cfg(any(feature = "bg_pg", feature = "bg_sqlt"))]
pub mod queue;
#[cfg(test)]
pub mod redis;
pub mod task;
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/task.rs | src/tests_cfg/task.rs | use crate::prelude::*;
#[derive(Debug)]
pub struct Foo;
#[async_trait]
impl Task for Foo {
fn task(&self) -> TaskInfo {
TaskInfo {
name: "foo".to_string(),
detail: "run foo task".to_string(),
}
}
async fn run(&self, _app_context: &AppContext, _vars: &task::Vars) -> ... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/queue.rs | src/tests_cfg/queue.rs | #[cfg(any(feature = "bg_pg", feature = "bg_sqlt"))]
use crate::bgworker;
use std::path::PathBuf;
#[cfg(feature = "bg_pg")]
/// # Panics
///
/// This function will panic if it fails to prepare or insert the seed data, causing the tests to fail quickly
/// and preventing further test execution with incomplete setup.
pub... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/redis.rs | src/tests_cfg/redis.rs | use redis::Client;
use std::time::Duration;
use testcontainers::{
core::{ContainerPort, WaitFor},
runners::AsyncRunner,
ContainerAsync, GenericImage,
};
/// Sets up a Redis test container.
///
/// # Returns
///
/// A tuple containing the Redis URL and the container instance.
///
/// # Panics
///
/// This f... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/postgres.rs | src/tests_cfg/postgres.rs | use sqlx::PgPool;
use std::time::Duration;
use testcontainers::{
core::{ContainerPort, WaitFor},
runners::AsyncRunner,
ContainerAsync, GenericImage, ImageExt,
};
/// Sets up a `PostgreSQL` test container.
///
/// # Returns
///
/// A tuple containing the `PostgreSQL` connection URL and the container instanc... | rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
loco-rs/loco | https://github.com/loco-rs/loco/blob/13984b401057515e321775ccbbed95a8d8463f5a/src/tests_cfg/controllers/home.rs | src/tests_cfg/controllers/home.rs | use crate::controller::Routes;
#[must_use]
pub fn routes() -> Routes {
Routes::new()
}
| rust | Apache-2.0 | 13984b401057515e321775ccbbed95a8d8463f5a | 2026-01-04T15:47:23.442679Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.