react-router icon indicating copy to clipboard operation
react-router copied to clipboard

fix responseStub

Open ryanflorence opened this issue 8 months ago • 5 comments

API is cumbersome, I'm thinking this:

function loader({ response }) {
  // change status
  response.status(404)

  // append/set headers
  response.headers.append('Cookie', 'foo=bar')
  response.headers.set('X-Foo', 'bar')

  // redirect (throws)
  response.redirect('/login')
  response.redirect(`/post/${newPostId}`, 303)

  // redirect with status and SET headers
  response.headers.set('Cookie', clearedCookie())
  response.redirect('/login', 303)

  // raise (throw) data and status to the error boundary
  response.raise('Not Found', 404)
}

ryanflorence avatar Jun 21 '24 17:06 ryanflorence