- Companion
- class
Type members
Classlikes
A cache that memoizes responses for eligible requests, and can cache response bodies of eligible responses
A cache that memoizes responses for eligible requests, and can cache response bodies of eligible responses
- Companion
- object
Value members
Concrete methods
Read a response from a path. Uses blocking I/O, so that a file on the local filesystem can be directly transferred to the connection using OS-level primitives when possible.
Read a response from a path. Uses blocking I/O, so that a file on the local filesystem can be directly transferred to the connection using OS-level primitives when possible.
Note that you mustn't use this method if the response may be cached, as
(depending on the request) it may produce a 304 Not Modified
response.
You don't want that being served to other clients! Use
- Value Params
- contentType
The
Content-Type
header to use for the response. Defaults toapplication/octet-stream
.- headers
Any additional headers to include in the response.
- path
A Path pointing to the file on the filesystem.
- request
The request to respond to. This is used:
- To check if the
If-Modified-Since
header value included in the request for this file. If given (in RFC 1123 format), an attempt will be made to determine if the file has been modified since the requested timestamp. If it hasn't, then the response returned will be a 304 Not Modified response with no body. - To provide the URI for a NotFound error, in case the path does not exist.
- To check if the
- status
The status of the response. Defaults to
Ok
(HTTP 200)
- Returns
A ZIO value which, when evaluated, will attempt to locate the given resource and provide an appropriate Response. If the resource isn't present, it will fail with HTTPError.NotFound. Since this response interacts with the filesystem, it can fail with other arbitrary Throwable failures; you'll probably need to catch these and convert them to HTTPError failures.
Read a response from a resource. Uses blocking I/O, so that a file on the local filesystem can be directly transferred to the connection using OS-level primitives when possible.
Read a response from a resource. Uses blocking I/O, so that a file on the local filesystem can be directly transferred to the connection using OS-level primitives when possible.
- Value Params
- classLoader
The class loader which can find the resource (defaults to this class's class loader)
- contentType
The
Content-Type
header to use for the response. Defaults toapplication/octet-stream
.- headers
Any additional headers to include in the response.
- name
The name (path) of the resource
- request
The request to respond to. This is used:
- To check if the
If-Modified-Since
header value included in the request for this file. If given (in RFC 1123 format), an attempt will be made to determine if the file has been modified since the requested timestamp. If it hasn't, then the response returned will be a 304 Not Modified response with no body. - To provide the URI for a NotFound error, in case the path does not exist.
- To check if the
- status
The status of the response. Defaults to
Ok
(HTTP 200)
- Returns
A ZIO value which, when evaluated, will attempt to locate the given resource and provide an appropriate Response. If the resource isn't present, it will fail with HTTPError.NotFound. Since this response interacts with the filesystem, it can fail with other arbitrary Throwable failures; you'll probably need to catch these and convert them to HTTPError failures.
Build a caching layer which can memoize and cache responses in memory for the duration of the server's lifetime.
Build a caching layer which can memoize and cache responses in memory for the duration of the server's lifetime.
Start a websocket request from a stream of uzhttp.websocket.Frame s.
Start a websocket request from a stream of uzhttp.websocket.Frame s.
- Value Params
- headers
Any additional headers to include in the response.
- output
A stream of websocket uzhttp.websocket.Frame s to be sent to the client.
- req
The websocket request that initiated this response.