hyperlane_techempower 0.1.15

A lightweight, high-performance, and cross-platform Rust HTTP server library built on Tokio. It simplifies modern web service development by providing built-in support for middleware, WebSocket, Server-Sent Events (SSE), and raw TCP communication. With a unified and ergonomic API across Windows, Linux, and MacOS, it enables developers to build robust, scalable, and event-driven network applications with minimal overhead and maximum flexibility.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use super::*;

impl ServerHook for RequestMiddleware {
    async fn new(_ctx: &mut Context) -> Self {
        Self
    }

    async fn handle(self, ctx: &mut Context) {
        ctx.get_mut_response()
            .set_version(HttpVersion::Http1_1)
            .set_header(CONNECTION, KEEP_ALIVE)
            .set_header(SERVER, HYPERLANE)
            .set_header(DATE, gmt())
            .set_status_code(200)
            .set_header(CONTENT_TYPE, APPLICATION_JSON);
    }
}