august.web
Install this source library with aug add https://github.com/GreenPandaStudios/augscript/src/stdlib/web --as web, then import its public names from web.
Signatures show result types and checked errors. See packages to pin a release and language constructs for built-in types.
Principal
record Principal(string subject, List<string> permissions)Immutable identity returned by the authentication adapter.
Authentication
capability AuthenticationVerify the request's credentials. null means unauthenticated; adapter failures raise HttpError.
Authentication.authenticate
authenticate(HttpRequest request) returns optional Principal unless HttpErrorUses Authentication.authenticate.
Authorization
capability AuthorizationDecide whether a verified identity has one named permission.
Authorization.authorize
authorize(Principal identity, string permission) returns bool unless HttpErrorUses Authorization.authorize.
RequestLogger
capability RequestLoggerObserve a completed HTTP exchange, including failures and disconnects.
RequestLogger.complete
complete(string method, string path, int status, int milliseconds)Uses RequestLogger.complete.
WebRequestLogger
WebRequestLogger() implements RequestLoggerEmit escaped JSON request metadata to standard error. Credentials and query strings are excluded.
WebRequestLogger.complete
complete(string method, string path, int status, int milliseconds)Uses RequestLogger.complete.
HttpClient
capability HttpClientMake outbound HTTP requests. TLS verifies the peer; callers handle redirects.
HttpClient.request
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> unless HttpErrorPerform an HTTP request with bounded bytes. Waiting for a response suspends the calling task.
Uses HttpClient.request.
WebHttpClient
WebHttpClient() implements HttpClientNative libwebsockets transport. No socket is opened by construction.
WebHttpClient.request
request(string method, string url, optional Headers headers, optional Bytes body) returns HttpResponse<Bytes> unless HttpErrorPerform an HTTP request with bounded bytes. Waiting for a response suspends the calling task.
Uses HttpClient.request.
redirect
redirect(string location, optional int status) returns HttpResponse<string> unless HttpErrorReturn a redirect with an explicit status. Location is checked as a header value.
urlEncode
urlEncode(string input) returns string unless HttpErrorEncode a UTF-8 value as one URL query or form component using RFC 3986 unreserved characters.
cookie
cookie(string name, string value, string path, int maxAge, bool secure) returns Headers unless HttpErrorConstruct an HttpOnly, SameSite=Lax session cookie. Secure defaults are chosen explicitly at the call site. Values and paths reject delimiters and controls. maxAge=0 clears the cookie.
ServerControl
capability ServerControlStop accepting requests, drain admitted exchanges up to the given milliseconds, then cancel remaining work. serve returns after request cleanup has joined.
ServerControl.stop
stop(int milliseconds) unless HttpErrorUses ServerControl.stop.
WebServerControl
WebServerControl() implements ServerControlControl the server on its event-loop thread. Owned services can be disposed after serve returns.
WebServerControl.stop
stop(int milliseconds) unless HttpErrorUses ServerControl.stop.