Skip to content

simple example of a HTTPS server written in Rust using the Axum framework

Notifications You must be signed in to change notification settings

juanmait/example-server-axum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example HTTP Server using Axum

This is just a simple example of a HTTPS server written in Rust using the Axum framework.

  • It have tracing instrumentation.
  • It implements basic in-memory sessions based on cookies.
  • It serves public static files.
  • It uses RustTLS for https which enables HTTP2 protocol (axum flag http2 must be enabled).
  • It supports brotli compression
# run the server
cargo run
# run the server in watch mode
cargo watch -q -c -w src/ -x run
# enable tower_http request/response tracing
RUST_LOG=example_server_axum=debug,tower_http=trace cargo run
# enable tower_http request/response tracing and run the server in watch mode
RUST_LOG=example_server_axum=debug,tower_http=trace cargo watch -q -c -w src/ -w public/index.html -x run

Note: you need to cargo install cargo-watch to use the watch mode.

TODOs

  • handle session not found for cookie found (BUG).
  • upgrade versions of axum, tower-http and axum-server.

Notes

Trait axum::extract::FromRequest

  • Things that can be created from a requests.
  • FromRequest is generic over the request body.

axum::response::IntoResponse

  • A response can be created from any type that implements IntoResponse.
  • Types that implement IntoResponse can be returned from handlers.

Read

Versioning

git tag v0.1.1
git push
git push --tags

About

simple example of a HTTPS server written in Rust using the Axum framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published