Crates.io | rust_web_framework |
lib.rs | rust_web_framework |
version | 0.1.6 |
source | src |
created_at | 2022-08-23 15:06:39.106647 |
updated_at | 2022-08-27 20:43:05.8399 |
description | Quickly crate API:s using this simple and lightweight framework. |
homepage | |
repository | |
max_upload_size | |
id | 651038 |
size | 30,438 |
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
}