preroll on crates.io Documentation (latest release)

preroll

Easy boilerplate utilities for Rust http services which use async-std, Tide, Surf, and friends.

Allows for service setup with feature-configured builtins for maximum service consistency with low developer overhead, and for easily integration testing the service without using a live network.

Scroll to the bottom for API Reference

Example

```rust use std::sync::Arc;

use tide::{Request, Route};

struct AppState { greeting: &'static str, }

type AppRequest = Request>;

async fn setupappstate() -> preroll::SetupResult { Ok(AppState { greeting: "Hello World!", }) }

fn setuproutes(mut server: Route<', Arc>) { server .at("hello-world") .get(|req: AppRequest| async move { Ok(req.state().greeting) }); }

// The "magic" happens here! preroll::main!("hello-world", setupappstate, setup_routes); ```

Features

Optional features

Add-on features must be enabled via cargo features, e.g.

toml [dependencies.preroll] version = "0.5" features = ["honeycomb", "postgres"]

List of optional add-on features:

List of other optional features:

General Environment Settings

The following environment variables are read during preroll::main!: - ENVIRONMENT: If this starts with prod, load the production-mode JSON logger, avoid .env. - FORCE_DOTENV: Override production-mode, force-load environment from .env. - HOST: Sets the hostname that this service will listen on. Defaults to "127.0.0.1". - LOGLEVEL: Set the logger's level filter, defaults to info in production-mode, debug in development-mode. - PORT: Sets the port that this service will listen on. Defaults to 8080.

Note:

This crate is intentionally somewhat prescriptive in how it templates a service and the interaction with add-on features such as Postgres (via SQLx).

API Reference

API Reference on Docs.rs

License

Licensed under the BlueOak Model License 1.0.0Contributions via DCO 1.1