Crate fregate

Source
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 call init_tracing and init_metrics fn.
configuration
See in examples how to configure your crate::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
AppConfigBuilder
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 if String starts with ‘/’ symbol.
Endpoints
By default endpoints are:
ManagementConfig
Management configuration. Currently only endpoints configuration is supported.
ObservabilityConfig
configuration for logs and traces

Enums§

ConfigSource
Enum to specify configuration source type:

Functions§

bootstrap
Reads AppConfig and calls init_tracing. Return Error if fails to read AppConfig or init_tracing returns error. Return Error if called twice because of internal call to [tracing_subscriber::registry().try_init()].