Giter Site home page Giter Site logo

catalyst's Introduction

Catalyst

CircleCI

Catalyst is a lightweight, fast and simple to use webserver written on top of tokio, rustls, and h2.

Getting Started

$ git clone https://github.com/technetos/catalyst.git

Building the project

$ cargo b --release

Running the examples

To run an example use $ cargo r --release --example <name_of_example>

To run the simple_routes example:

$ cargo r --release --example simple_routes
Listening on: 127.0.0.1:3000

The simple_routes example has the following routes

Method URI Payload Expected Response
GET https://127.0.0.1:3000/index JSON "hello!"

Basic Usage

struct HomePage;

impl Route for HomePage {
    type Body = Json;
    type Future = RouteF<Response>;

    fn handle_request(req: Request<Self::Body>) -> Self::Future {
        let parts = req.parts();

        let user_settings = req.body().inner();

        let res = Response::new()
            .status(http::StatusCode::OK)
            .content_type("application/json")
            .body(json_bytes_ok!(json!("hello!")));

        boxed!(OkFut(res))
    }
}

use http::Method;

fn main() -> Result<(), Box<StdError>> {
    // Configure the server.
    let config: Config = Config::parse_config()?;

    // Define the routes.
    let mut routing_table = RoutingTable::new();
    routing_table
        .at("/index", Method::GET)
        .attach(HomePage);
        
    // Start the server.
    start_server(config, routing_table)?;
    Ok(())
}

catalyst's People

Contributors

rupsis avatar technetos avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

catalyst's Issues

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.