rust_web_framework

Crates.iorust_web_framework
lib.rsrust_web_framework
version0.1.6
sourcesrc
created_at2022-08-23 15:06:39.106647
updated_at2022-08-27 20:43:05.8399
descriptionQuickly crate API:s using this simple and lightweight framework.
homepage
repository
max_upload_size
id651038
size30,438
Artur (Arturr-H)

documentation

README

Rust web framework

Easy to use, easy to set up.

use rust_web_framework::*;

/*- Initialize -*/
fn main() {

    /*- Initiaize routes -*/
    let routes = Route::Stack("", &[
        Route::Stack("path", &[
            Route::Tail(Method::GET, "enpoint", Function::S(some_function)),
            Route::Tail(Method::GET, "enpoint2", Function::S(some_other_function)),
        ]),
    ]);

    /*- Initiaize server -*/
    start(ServerConfig {
        addr: "127.0.0.1", // This will be localhost, use 0.0.0.0 if using docker
        port: 8080u16,     // Self explanatory
        serve: Some("./static"),              // Serve static files from a folder
        not_found: Some("./static/404.html"), // Where to direct users going to a path which doesn't exist
        routes,
    }).unwrap();

    // Go to 'localhost:8080/path/enpoint' to see results
}
Commit count: 0

cargo fmt