How to redirect requests from domain.com to www.do

2019-09-11 01:17发布

My site is built in Haskell/Servant and Wai/Warp. I need to redirect all requests from my domain.com to www.domain.com with the the 301 or 302 status. I know I can do that with the help of Wai/Warp somehow. How exactly?

startApp :: IO ()
startApp = run 1234 app

1条回答
SAY GOODBYE
2楼-- · 2019-09-11 01:47

The package wai-util has a convenience function redirect' to create such a Response, so you should be able to do something like

app :: Application
app req respond = respond =<< redirect' status302 [] uri
  where
    Just uri = parseURI "http://example.com/"
查看更多
登录 后发表回答