getRequestHost function
Get incoming request host
Extracts the host header from the incoming HTTP request. This typically returns the domain name or IP address (and optionally port) that the client used to make the request.
router.get("/home", (event) {
String? host = getRequestHost(event); // e.g. "example.com" or "localhost:8080"
});
Returns null if the host header is not present.
Implementation
String? getRequestHost(H4Event event) {
return event.node["value"]?.headers.value(HttpHeaders.hostHeader);
}