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
AppConfig
and callinit_tracing
andinit_metrics
fn. - configuration
- See in
examples
how 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
::metrics
and::tracing
crates. - 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
String
but it checks ifString
starts with ‘/’ symbol. - Endpoints
- By default endpoints are:
- Management
Config Management
configuration. 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 readAppConfig
orinit_tracing
returns error. Return Error if called twice because of internal call to [tracing_subscriber::registry().try_init()
].