Code Monkey home page Code Monkey logo

hsr's Introduction

HSR

Build fast HTTP apis fast, with Rust, and OpenAPI

  • Define your API as an OpenAPI 3.0 spec
  • HSR will code-gen a server/client interface
  • Implement your interface (simple, safe, strongly typed!)
  • Run! 'If it compiles, it works!'

Docs

Quickstart

Take a look at the quickstart example. It contains the minimum boilerplate needed to get up and running.

Tutorial

Read the tutorial for a step-by-step guide to get up and running.

Less Quick Start

Take a look at the petstore example for a more complex example with a mocked database backend.

Features

  • HTTP server
  • HTTP client
  • Type-safe path/query/json handling
  • Supports all HTTP verbs
  • High performance
  • Based on async/await and actix-web 2.0

FAQ

What's the difference between this and swagger-rs?

I haven't used swagger-rs, however the major difference is that hsr is pure Rust, whereas swagger-rs takes advantage of an existing code-generator written in Java. That means that the swagger-rs is more mature likely much more correct, hsr is much easier to use and is seamlessly integrated into typical Rust workflow.

What do you mean, 'fast'?

It uses Actix-Web under the hood, rated as one of the fastest web frameworks by techempower. hsr imposes very little overhead on top.

As a simple and not-very-scientific benchmark, on my laptop (X1 Carbon 6th Gen) I measured around:

  • 120,000 requests/second for an empty GET request
  • 100,000 requests/second for a POST request with a JSON roundtrip

Try it yourself! See the bench example.

Why the name?

I like fast trains.

License

MIT

hsr's People

Contributors

adwhit avatar

Watchers

 avatar

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.