/// Who sent a request: the `client` effect, and `behind`, its handler /// for a server that may sit behind proxies. import std/http.{type Request} import std/option /// The address a request came from. pub effect client { fn address :: req: Request -> String } /// Runs `action`, answering `address` with the peer, or with the /// `X-Forwarded-For` client when the peer is one of the `trusted` /// proxies; `"unknown"` for a request without a peer. pub fn behind :: trusted: List action: fn() -> a / -> a / { handle { action () } with { address req -> http.client_address req trusted |> option.unwrap_or "unknown" } }