Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Shio is a fast, simple, and asynchronous micro web-framework for Rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

mehcode/shio-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RustBuild StatusCoverage StatusCrates.ioCrates.ioDocs.rsIRC

Shio is a fast, simple, and asynchronous micro web-framework for Rust.

  • Asynchronous. Handlers are both handledasynchronously and may beasynchronous themselves. Ashio::Handler receives atokio_core::reactor::Handle which 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 bytokio.

  • Stability. Shio is fully committed to working and continuing to work onstable Rust.

Usage

[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();}

Examples

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()))}}

Even More Examples

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

License

Licensed under either of

at your option.

Contribution

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

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Contributors4

  •  
  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp