···1111- Added `content_security_policy_protection` middleware for nonce-based strict CSP headers.
1212- Added `as_file_download` for sending responses with `Content-Disposition: attachment`.
1313- Added automatic `ETag` and `Last-Modified` headers for `send_file` responses and `cache` middleware for conditional requests.
1414+- Added `last_modified` to set the header of the same name.
14151516### Changed
1617
···104104//// [server_sent_events](#server_sent_events "Send a SSE stream response"),
105105//// [websocket](#websocket "Open a websocket connection"),
106106//// [with_status](#with_status "Set the status of a response"),
107107+//// [last_modified](#last_modified "Set the Last-Modified header of a response"),
107108//// [with_extra_headers](#with_extra_headers "Add some headers to a response"),
108109//// [as_file_download](#as_file_download "Send a response as a file download"),
109110//// [send](#send "Helper for chunked/SSE/Websocket responses"),
···12151216 #("content-length", int.to_string(content_length)),
12161217 #("content-type", content_type),
12171218 #("etag", generate_etag(file.size, file.mtime)),
12181218- #(
12191219- "last-modified",
12201220- format_http_date(file.mtime),
12211221- ),
12191219+ #("last-modified", format_http_date(file.mtime)),
12221220 ]),
12231221 )
12241222 }
···15491547) -> Promise(Response) {
15501548 use response <- promise.await(response)
15511549 promise.resolve(Response(..response, status:))
15501550+}
15511551+15521552+/// Convenience function to set the `Last-Modified` header on a response from a
15531553+/// `Timestamp`.
15541554+///
15551555+/// Pairs with the [`cache`](#cache) middleware, which uses the header to respond
15561556+/// with `304 Not Modified` for conditional requests.
15571557+///
15581558+/// ## Example
15591559+///
15601560+/// ```gleam
15611561+/// smol.send_html(render_post(post))
15621562+/// |> smol.last_modified(at: post.updated_at)
15631563+/// ```
15641564+///
15651565+pub fn last_modified(
15661566+ response: Promise(Response),
15671567+ at timestamp: Timestamp,
15681568+) -> Promise(Response) {
15691569+ with_extra_headers(response, [#("last-modified", format_http_date(timestamp))])
15521570}
1553157115541572/// Convenience function to add headers to a response.