···305305 HttpResponse(202, [], Empty)
306306}
307307308308+/// Create an empty response with status code 303: See Other, and the `location`
309309+/// header set to the given URL. Used to redirect the client to another page.
310310+///
311311+/// # Examples
312312+///
313313+/// ```gleam
314314+/// redirect(to: "https://example.com")
315315+/// // -> Response(303, [#("location", "https://example.com")], Empty)
316316+/// ```
317317+///
318318+pub fn redirect(to url: String) -> Response {
319319+ HttpResponse(303, [#("location", url)], Empty)
320320+}
321321+322322+/// Create an empty response with status code 308: Moved Permanently, and the
323323+/// `location` header set to the given URL. Used to redirect the client to
324324+/// another page.
325325+///
326326+/// This redirect is permanent and the client is expected to cache the new
327327+/// location, using it for future requests.
328328+///
329329+/// # Examples
330330+///
331331+/// ```gleam
332332+/// moved_permanently(to: "https://example.com")
333333+/// // -> Response(308, [#("location", "https://example.com")], Empty)
334334+/// ```
335335+///
336336+pub fn moved_permanently(to url: String) -> Response {
337337+ HttpResponse(308, [#("location", url)], Empty)
338338+}
339339+308340/// Create an empty response with status code 204: No content.
309341///
310342/// # Examples
+19
test/wisp_test.gleam
···3232 |> should.equal(Response(204, [], wisp.Empty))
3333}
34343535+pub fn redirect_test() {
3636+ wisp.redirect(to: "https://example.com/wibble")
3737+ |> should.equal(Response(
3838+ 303,
3939+ [#("location", "https://example.com/wibble")],
4040+ wisp.Empty,
4141+ ))
4242+}
4343+4444+pub fn moved_permanently_test() {
4545+ wisp.moved_permanently(to: "https://example.com/wobble")
4646+ |> should.equal(Response(
4747+ 308,
4848+ [#("location", "https://example.com/wobble")],
4949+ wisp.Empty,
5050+ ))
5151+}
5252+3553pub fn internal_server_error_test() {
3654 wisp.internal_server_error()
3755 |> should.equal(Response(500, [], wisp.Empty))
···245263}
246264247265pub fn rescue_crashes_error_test() {
266266+ // TODO: Determine how to silence the logger for this test.
248267 {
249268 use <- wisp.rescue_crashes
250269 panic as "we need to crash to test the middleware"