【发布时间】:2017-09-14 06:19:42
【问题描述】:
我的 Yesod-Application 应该通过 Envoirement-Variable 获得它的 approot。 This 似乎正是描述了这种情况。但是:这样做时,只有 Yesod 生成的链接会考虑 approot,但 Quasiquoter parseRoutes 中的 Route-definitions 将保持绝对:
mkYesod "App" [parseRoutes|
/ HomeR GET
|]
因此,将 APPROOT 设置为“domain.com/path”将不起作用,因为“/path”没有路由,而只有“/”。
有没有办法让路由相对于approot?
更新:
我也尝试相应地修改 cleanPath,但是到 Home-Route 的路由仍然是错误的……
instance Yesod Browser where
approot = ApprootMaster myApproot
cleanPath site s = do
if corrected == s
then Right $ dropprefix (Data.List.map dropDash s)
else Left $ dropprefix corrected
where
corrected = Data.List.filter (not . Data.Text.null) s
dropDash t
| Data.Text.all (== '-') t = Data.Text.drop 1 t
| otherwise = t
r = Data.Text.drop 1 $ myApproot site
l = Data.Text.length r
dropprefix l
| Data.List.take 1 l == [r] = Data.List.drop 1 l
| otherwise = l
如果我将 approot 设置为“/foo”,它会起作用,但“@{HomeR}”会导致“/foo/”重定向到“/foo/foo”……
【问题讨论】: