actix-route-config

Crates.ioactix-route-config
lib.rsactix-route-config
version0.1.1
sourcesrc
created_at2023-05-17 20:07:53.103277
updated_at2023-05-17 20:11:31.150046
descriptionAllow clean configuration of Actix Web routes
homepage
repositoryhttps://github.com/TobiasDeBruijn/actix-route-config
max_upload_size
id867189
size4,483
Tobias de Bruijn (TobiasDeBruijn)

documentation

README

Actix-route-config

Allow clean configuration of actix-web routes.

Explanation

I like the concept of 'routers' to configure my Actix web servers. This trait specifies a function configure which can be called directly from Actix's configure method.

Example

use actix_route_config::Routable;
use actix_web::web;

pub struct Router;

impl Routable for Router {
    fn configure(config: &mut ServiceConfig) {
        config.service(web::scope("/api")
            // Assuming there's a submodule `foo` with a handler function `foo`
            .route("/foo", web::get().to(foo:foo))
        );
    }
}

This will create a route /api/foo ending up at the foo::foo function.

License

This project is licensed under:

At your option.

Commit count: 4

cargo fmt