13 releases
0.1.4 | Jan 11, 2022 |
---|---|
0.1.3 | Dec 22, 2021 |
0.1.2 | Sep 17, 2021 |
0.0.9 | Feb 12, 2021 |
#2359 in Web programming
49 downloads per month
51KB
755 lines
micro_http_async
What is it for?
A small, lightweight crate using async to serve web pages or web apis with high performance and low overhead.
How do I use it?
Firstly, install the crate and dependencies:
[dependencies]
micro_http_async = "*"
tokio = "1.11.0"
And if you want to support JSON:
serde_json = "1.0"
serde = {version = "1.0", features = ["derive"]}
This crate is designed to abstract away many of the low level code required to run a safe, asynchronous web server
Here is a small example which shows how to route, use asynchronous call backs and load webpage templates from HTML files.
For the HTML files included, please go to the repository and check the templates
folder.
Static files also included.
To run the included example (which is the example seen below), run cargo run --example hello_world
, and visit 127.0.0.1:8080
Please note this is probably not the final API
This crate aims only to simplify web api or lightweight web creation - not intended to run full scale web apps like chatrooms or other high intensity applications. It implements a simple asynchronous routing system (Made using hash maps for speed and efficiency) as well as asynchronous file loading and more.
It also supports TLS if security is a requirement through the rustls and tokio-rustls crates.
Changelog v0.1.4: TLS support is now available. See the hello_world example for an example on usage.
Dependencies
~13–28MB
~466K SLoC