如何在Yesod中更改子网站的URL?

时间:2018-03-07 21:53:14

标签: haskell yesod

是否可以在Yesod中重命名子网站的端点?

例如,我不想使用/login中提供的/email/registeryesod-auth,而是将其称为" / entrar"和" / cadastrar" (分别是他们的PT-BR对手)。

我设法做到这一点的唯一方法是将HTML <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href="website.html"> <link rel="stylesheet" type="text/css" href="topfightercss.css"> <h1><u>Top Fighters</u></h1> </head> <body> <div id="demetrious"> <img src="dem.png" alt="Demetrious Johnson"> <p> Demetrious Johnson is the rank 1 pound for pound fighter in UFC,<br>he is from Kentucky USA and is aged 31 and stands at 5'3 (160cm)<br>he weights 56kg (125lb) and has a reach of 66" with a leg reach of 34".<br>He has a record of 27 wins 2 losses and 1 draw and is the curent<br> flyweight champion. </p> </div> <div id="connor"> <img scr="connor.png" alt="Connor Mcgegor"> </div> <div id="daniel"> <img scr="daniel.png" alt="Daniel Cormier"> </div> </body> </html> CSS html { background: url(pg2background.jpg); background-attachment: fixed; background-position: center center; background-repeat: no-repeat; background-size: cover; } h1 { color: aqua; text-align: center; font-size:24pt; } .demetrious { position: relative; top: 8px; left: 12px; width: 450px; height: 300px; opacity: 0.3; } p { color: aliceblue; } .connor { position: center; top: 8px; right:12px; } .daniel { position: relative; } 设置为使用stack.yaml的修改后的本地副本,但我想知道是否有更好的方法。

1 个答案:

答案 0 :(得分:2)

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