velen 0.1.8

A simple package for making REST APIs
Documentation
velen-0.1.8 has been yanked.

Velen

Just another REST framework

How to use

Import

use velen::models::server_models::{Request, Response};

Create server instance

Register endpoints

server.post("/add", post_handler);

Start listening

Example handlers

Read Query Params

req.query_params.get("user_id").unwrap();

Read Request Header

req.headers.get("x-custom-header").unwrap();

Read Request Body

req.body;

Set Response Status

res.set_status_code(200);

Set Response header

res.set_header("Content-Type", "application/json");

Set Response payload

res.send("{"status":"ok"}");

Limitations

  • OPTIONS not implemented
  • Only application/json is supported, so don't try to upload files
  • During sending a response set_status_code has to be called before any set_header. That is how response is actually sent to client.
  • No multithreading

TODO

  • Fix above limitations