-
Notifications
You must be signed in to change notification settings - Fork 374
Overriding approot
Murray edited this page Mar 4, 2016
·
4 revisions
This page demonstrates different ways you may wish to override the approot
method.
This will use no root at all. Keep in mind this will not work with emails and RSS feeds.
approot = ApprootRelative
Note absence of trailing slash
approot = ApprootStatic "http://localhost"
Get a static application root from runtime configuration stored in the foundation datatype:
approot = ApprootMaster $ appRoot . appSettings
This will use the approot from appSettings but fall back to the http host
header field
approot = ApprootRequest $ \app req ->
case appRoot $ appSettings app of
Nothing -> getApprootText guessApproot app req
Just root -> root
app
here is the master site and req
is the request.
This will get the approot from the request header host
field:
approot = guessApproot
Same as above but instead of guessing if links should be https(based on the X-Forwarded-Proto
header for example) will only make links https://
if the connection is actually secure.
import Network.Wai (requestHeaderHost, isSecure)
approot = ApprootRequest $ \_ r -> maybe ""
(mappend (if isSecure r then "https://" else "http://") . decodeUtf8)
(requestHeaderHost r)