Giter VIP home page Giter VIP logo

amiya's Introduction

Amiya

Badge with github icon Badge with document icon

Amiya is a experimental middleware-based minimalism async HTTP server framework, built up on smol-rs related asynchronous components.

It's currently still working in progress and in a very early alpha stage.

API design may changes, DO NOT use it in any condition except for test or study!

Goal

The goal of this project is try to build a (by importance order):

  • Safe, with #![forbid(unsafe_code)]
  • Async
  • Middleware-based
  • Minimalism
  • Easy to use
  • Easy to extend

HTTP framework for myself to write simple web services.

Amiya uses async-h1 to parse and process requests, so only HTTP version 1.1 is supported for now. HTTP 1.0 or 2.0 is not in goal list, at least in the near future.

Performance is NOT in the list too, after all, Amiya is just a experimental for now, it uses many heap alloc (Box) and dynamic dispatch (Trait Object) so there may be some performance loss compare to use async-h1 directly.

Have a Taste

To start a very simple HTTP service that returns Hello World to the client in all paths:

use amiya::m;

fn main() {
    let app = amiya::new().uses(m!(ctx =>
        ctx.resp.set_body(format!("Hello World from: {}", ctx.path()));
    ));

    app.listen("[::]:8080").unwrap();

    // ... do other things you want ...
    // ... Amiya server will not block your thread ...
}

Amiya has a built-in multi-thread async executor powered by async-executor and async-io, http server will run in it. So Amiya::listen is just a normal non-async method, and do not block your thread.

Examples

To run examples, run

cargo run --example # show example list
cargo run --example hello # run hello

Top level document of crate has a brief description of concepts used in this framework, I recommend give it a read first, and then check those examples to get a more intuitive understanding:

Most of those example will use builtin executor, see example/tokio_executor.rs for how to use a custom executor with Amiya.

License

BSD 3-Clause Clear License, See LICENSE.

amiya's People

Contributors

7sdream avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

atnightly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.