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
- See in
exampleshow to configure yourcrate::Application - fregate Errors
- Extensions traits for different crates
- Trait to implement custom Health checks
- Set of middlewares
- Collection of syntax-sugar-like functions
Macros
- Example:
- Example:
Structs
- AppConfig reads and saves application configuration from different sources
- AppConfig builder to set up multiple sources
- Application to set up HTTP server with given config
AppConfig - Default private config for
AppConfig. - By default endpoints are:
Managementconfiguration. Currently only endpoints configuration is supported.- configuration for logs and traces
Enums
- Enum to specify configuration source type:
Functions
- 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()].