Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the URLs of a subsite in Yesod?

Tags:

haskell

yesod

Is it possible to rename the endpoints of a subsite in Yesod?

For instance, instead of using the provided /login or /email/register from yesod-auth, I want to call them "/entrar" and "/cadastrar" (their PT-BR counterparts, respectively).

The only way I managed to do that was by setting my stack.yaml to use a modified local copy of yesod-auth, but I wonder if there's a better approach.

like image 936
Alexandre Lucchesi Avatar asked Mar 07 '18 21:03

Alexandre Lucchesi


1 Answers

Currently the YesodAuth datatype doesn't provide a way to change those routes, so you have two options as far as I know:

  1. Have a local copy of yesod-auth and modify it according to your needs (What you're doing right know)

  2. Have the routes you want in config/routes and a handler for each of them that will redirect to the yesod-auth routes:

config/routes

/entrar MyauthEntrarR GET

src/Handler/Myauth

getMyauthEntrar :: Handler Html

getMyauthEntrar = redirect LoginR
like image 122
Daniel Campoverde - alx741 Avatar answered Oct 01 '22 07:10

Daniel Campoverde - alx741