- Notifications
You must be signed in to change notification settings - Fork11
Shio is a fast, simple, and asynchronous micro web-framework for Rust.
License
Apache-2.0, MIT licenses found
Licenses found
mehcode/shio-rs
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Shio is a fast, simple, and asynchronous micro web-framework for Rust.
Asynchronous. Handlers are both handledasynchronously and may beasynchronous themselves. A
shio::Handlerreceives atokio_core::reactor::Handlewhich may be used to schedule additional work on the thread-local event loop.Multithreaded. By default, requests are handled by multiple threads, each running an event loop powered by
tokio.Stability. Shio is fully committed to working and continuing to work onstable Rust.
[dependencies]shio ="0.2.0"
externcrate shio;use shio::prelude::*;fnhello_world(_:Context) ->Response{Response::with("Hello World!\n")}fnhello(ctx:Context) ->Response{Response::with(format!("Hello, {}!\n",&ctx.get::<Parameters>()["name"]))}fnmain(){Shio::default().route((Method::GET,"/", hello_world)).route((Method::GET,"/{name}", hello)).run(":7878").unwrap();}
A request handler is a value that implements theshio::Handler trait.
Handlers arenot cloned on each request and therefore may contain state.Note that any fields must beSend + Sync.
externcrate shio;use std::thread;use std::sync::atomic::{AtomicUsize,Ordering};use shio::prelude::*;#[derive(Default)]structHandlerWithState{counter:AtomicUsize,}impl shio::HandlerforHandlerWithState{typeResult =Response;fncall(&self, _:Context) ->Self::Result{let counter =self.counter.fetch_add(1,Ordering::Relaxed);Response::with(format!("Hi, #{} (from thread: {:?})\n", counter, thread::current().id()))}}
Many more usageexamples/ are included with Shio.
Examples may be ran withcargo run -p <example name>.For instance, to run thehello example, use:
$ cargo run -p hello
Licensed under either of
- Apache License, Version 2.0(LICENSE-APACHE orhttp://www.apache.org/licenses/LICENSE-2.0)
- MIT license(LICENSE-MIT orhttp://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall bedual licensed as above, without any additional terms or conditions.
About
Shio is a fast, simple, and asynchronous micro web-framework for Rust.
Topics
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors4
Uh oh!
There was an error while loading.Please reload this page.