Reputation: 1437
I have to set a location header in a post handler response, putting the location where the newly created entity is placed. How can I do it dynamically?
The target route (where it will be placed) has this definition:
/exchanges/#ExchangeId ExchangeByIdR GET PUT
EDIT
I would like a function like this one:
addLocationHeader (ExchangeByIdR eId)
Upvotes: 0
Views: 79
Reputation: 1437
I simply created my own function addLocationHeader
:
addLocationHeader :: MonadHandler m => Route (HandlerSite m) -> m ()
addLocationHeader url = do
r <- getUrlRender
addHeader "Location" (r url)
Upvotes: 1