Coder Social home page Coder Social logo

rest_server's Introduction

rest_server

This program is a minimal REST server framework in rust

Warning!

This program is still in development

Feature to add:

I'm only support http/1.1 and won't support 2.0

Usage example

fn main() {
    let mut app: Server = Server::new();
    app.set_number_of_worker(8);
    app.get(String::from("/"), Box::new(index));
    app.listen(7878);
    println!("Shutting down.")
}

fn index(_request: Request, mut response: Response) {
    let content = "Hello";
    response.set_status(Status::from(200));
    response.set_body(content);
    response.send();
}

Contribution

If you have an idea to implement, please post a issue, I'll receive PR about this fonctionnality after I validated it on issues page.

rest_server's People

Contributors

quentinlegot avatar

Watchers

 avatar

rest_server's Issues

[FEATURE] Route parameters

Is your feature request related to a problem? Please describe.
Can't set uri path like: /users/:id/profile and get the id

Describe the solution you'd like
Something like app.get('/users/:id/profile') and when client send a request at /users/5/profile, request.get_param('id') return 5

Additional context
Express.js actually have this functionnality

[BUG] server route is static and we can't create 2 servers on the same app

Describe the bug
server routing is a static variable and is used by every Server instance, modifying one server route will have the same effect on every other server

To Reproduce

  1. Create 2 servers
  2. Make differents routing for them
  3. Listen on different port (create 1 thread per server)
  4. Try a route for server 1 on server 2 port and you'll see server 1 result

Expected behavior
Route should be defined per servers

[FEATURE] Parsing request query

Is your feature request related to a problem? Please describe.
When user send a content throught url with get method: /user?id=5
We want req.query('id') to return 5

[FEATURE] Parsing request header and send response header

Is your feature request related to a problem? Please describe.
Cannot currently parse header and send header in response

Describe the solution you'd like
When a request is make, headers are already parsed and possibility to add header in response

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.