Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technetos/catalyst
A fast and simple webserver
https://github.com/technetos/catalyst
alpn http2 rust tls tokio webserver
Last synced: 4 days ago
JSON representation
A fast and simple webserver
- Host: GitHub
- URL: https://github.com/technetos/catalyst
- Owner: technetos
- License: apache-2.0
- Created: 2018-12-26T19:17:25.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-19T03:00:59.000Z (over 5 years ago)
- Last Synced: 2024-11-07T18:52:00.501Z (about 2 months ago)
- Topics: alpn, http2, rust, tls, tokio, webserver
- Language: Rust
- Homepage:
- Size: 50.8 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Catalyst
[![CircleCI](https://circleci.com/gh/technetos/catalyst/tree/master.svg?style=svg)](https://circleci.com/gh/technetos/catalyst/tree/master)
Catalyst is a lightweight, fast and simple to use webserver written on top of tokio, rustls, and h2.
## Getting Started
```sh
$ git clone https://github.com/technetos/catalyst.git
```## Building the project
```sh
$ cargo b --release
```
## Running the examples
To run an example use `$ cargo r --release --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 routesMethod | URI | Payload | Expected Response
--- | --- | --- | ---
`GET` | `https://127.0.0.1:3000/index` | JSON | `"hello!"`## Basic Usage
```rust
struct HomePage;impl Route for HomePage {
type Body = Json;
type Future = RouteF;fn handle_request(req: Request) -> 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> {
// 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(())
}
```