Expand description
Web server handling API
This module contains facilities needed to process HTTP requests.
§Register Web Handler
To register web handler it’s usually enoght to use the attribute:
use edgedb_sdk::web;
#[web::handler]
fn web_handler(req: web::Request) -> web::Response {
web::response()
.status(web::StatusCode::OK)
.header("Content-Type", "text/html")
.body("Hello <b>World</b>".into())
.expect("response is built")
}§Programmatically Register Web Handler
It’s sometimes useful to do that programmatically. This is usually done in
init_hook and register_handler():
use edgedb_sdk::{init_hook, web};
#[init_hook]
fn init() {
web::register_handler(web_handler);
}
fn web_handler(req: web::Request) -> web::Response {
todo!();
}Structs§
- Request
- Web Request
- Status
Code - An HTTP status code (
status-codein RFC 7230 et al.).
Functions§
- register_
handler - Register a function as a web handler
- response
- Create a response builder
Type Aliases§
Attribute Macros§
- handler
- Register web handler