BloomResponse.redirect constructor

BloomResponse.redirect(
  1. String location, {
  2. int statusCode = 302,
})

Helper factory constructor for HTTP redirects.

Sets the Location: [location] header with the specified statusCode (default 302 Found).

Example

return BloomResponse.redirect('/login', statusCode: 303);

Implementation

factory BloomResponse.redirect(String location, {int statusCode = 302}) {
  return BloomResponse(
    statusCode: statusCode,
    headers: {'location': location},
    body: Uint8List(0),
  );
}