Expand description
Set of instruments to simplify http server set-up.\
This project is in progress and might change a lot from version to version.
Example:
use fregate::{
axum::{routing::get, Router},
bootstrap, tokio, AppConfig, Application,
};
async fn handler() -> &'static str {
"Hello, World!"
}
#[tokio::main]
async fn main() {
let config: AppConfig = bootstrap([]).unwrap();
Application::new(config)
.router(Router::new().route("/", get(handler)))
.serve()
.await
.unwrap();
}§Examples
Examples can be found here.
Re-exports§
pub use axum;pub use config;pub use hyper;pub use thiserror;pub use tokio;pub use tonic;pub use tower;pub use tower_http;pub use tracing;pub use tracing_subscriber;pub use valuable;
Modules§
- bootstrap
- This is a shortcut fn to read
AppConfigand callinit_tracingandinit_metricsfn. - configuration
- See in
exampleshow to configure yourcrate::Application - error
- fregate Errors
- extensions
- Extensions traits for different crates
- health
- Trait to implement custom Health checks
- middleware
- Set of middlewares
- observability
- This is a collection of useful functions and structs to be used with
::metricsand::tracingcrates. - sugar
- Collection of syntax-sugar-like functions
- version
- Trait to implement custom version response
Macros§
- static_
assert - Example:
- static_
trait_ assert - Example:
Structs§
- AppConfig
- AppConfig reads and saves application configuration from different sources
- AppConfig
Builder - AppConfig builder to set up multiple sources
- Application
- Application to set up HTTP server with given config
AppConfig - Empty
- Default private config for
AppConfig. - Endpoint
- This is simply a wrapper over
Stringbut it checks ifStringstarts with ‘/’ symbol. - Endpoints
- By default endpoints are:
- Management
Config Managementconfiguration. Currently only endpoints configuration is supported.- Observability
Config - configuration for logs and traces
Enums§
- Config
Source - Enum to specify configuration source type:
Functions§
- bootstrap
- Reads AppConfig and calls
init_tracing. Return Error if fails to readAppConfigorinit_tracingreturns error. Return Error if called twice because of internal call to [tracing_subscriber::registry().try_init()].