2 releases
Uses new Rust 2024
new 0.1.1 | May 2, 2025 |
---|---|
0.1.0 | Mar 9, 2025 |
#449 in WebSocket
103 downloads per month
39KB
916 lines
Hyper echo
Hyper echo is an echo server empowered by tokio, tower, hyper and fastwebsockets. It supports both HTTP and WebSocket protocols, making it ideal for testing and debugging network applications. It is available as a standalone binary or as a crate.
💡Features
HTTP
- Echoes back any received request (except websocket upgrade)
- Supports both HTTP/1.1 and HTTP/2
- Customizable logging levels:
0
: No logging (default)1
: Log the request URI2
: Log the request URI and headers3
: Log the request URI, headers and body
WebSocket
- Echoes received message back to the client
- Logging of received messages (off by default)
- Sends periodic pings (every 5 seconds by default) to keep connections alive and disconnects inactive clients
Other
- Colorful log output when the output is a terminal
- Choose your desired port or let
hyper_echo
automatically find a free one - Supports multi-threading, but efficient enough to use only one thread by default
- Graceful shutdown on
Ctrl-C
and force exit on the secondCtrl-C
Use the flag --help
to discover CLI options for customizing the behavior of hyper_echo
.
🌐 Links
- crates.io: https://crates.io/crates/hyper_echo
- docs.rs: https://docs.rs/hyper_echo
⚙️ HTTP logging implementation
There are two crate's features controlling HTTP logging:
tower_trace
(default) is based on Trace from tower_http cratecustom_trace
is a layer for tower service written from scratch
Both implementations are almost identical from a user perspective.
There is no real reason to use logging implementation provided by custom_trace
feature.
It was created to learn how to create a custom tower layer and how to handle multiple features in one crate.
But if in some case you want to use it, please don't forget to add default-features = false
if you are using custom_trace
because
it is possible to use only one logging implementation at a time.
🙏 Acknowledgements
Thanks to David Peterson for the Tower deep dive video explained for me how to use tower.
Dependencies
~13–24MB
~343K SLoC