Advanced
More utilities
Session utils
_kGetSession
- Type:
symbol
- Default:
undefined
clearSession(event, config)
Clear the session data for the current request.
getSession(event, config)
Get the session for the current request.
sealSession(event, config)
Encrypt and sign the session data for the current request.
unsealSession(_event, config, sealed)
Decrypt and verify the session data for the current request.
updateSession(event, config, update?)
Update the session data for the current request.
useSession(event, config)
Create a session manager for the current request.
Cookie utils
deleteCookie(event, name, serializeOptions?)
Remove a cookie by name.
getCookie(event, name)
Get a cookie value by name.
parseCookies(event)
Parse the request to get HTTP Cookie header string and returning an object of all cookie name-value pairs.
setCookie(event, name, value, options?)
Set a cookie value by name.
Sanitize
sanitizeStatusCode(statusCode?, defaultStatusCode)
Make sure the status code is a valid HTTP status code.
sanitizeStatusMessage(statusMessage)
Make sure the status message is safe to use in a response.
Allowed characters: horizontal tabs, spaces or visible ascii characters: https://www.rfc-editor.org/rfc/rfc7230#section-3.1.2
Route
Cache
handleCacheHeaders(event, opts)
Check request caching headers (If-Modified-Since
) and add caching headers (Last-Modified, Cache-Control) Note: public
cache control will be added by default
Proxy
fetchWithEvent(event, req, init?, options?: { fetch: F })
Make a fetch request with the event's context and headers.
getProxyRequestHeaders(event)
Get the request headers object without headers known to cause issues when proxying.
proxyRequest(event, target, opts)
Proxy the incoming request to a target URL.
sendProxy(event, target, opts)
Make a proxy request to a target URL and send the response back to the client.