add option to change the app base URL

master
rnhmjoj 2017-02-21 16:22:57 +01:00
parent 0e9c0f45e0
commit 56b0689b04
No known key found for this signature in database
GPG Key ID: 362BB82B7E496B7C
1 changed files with 19 additions and 19 deletions

View File

@ -34,29 +34,29 @@ settings = do
urlsPath <- getUserDataFile "breve" "" urlsPath <- getUserDataFile "breve" ""
configPath <- getUserConfigFile "breve" "" configPath <- getUserConfigFile "breve" ""
config <- load [Required configPath] config <- load [Required configPath]
host <- lookupDefault "localhost" config "hostname" host <- lookupDefault "localhost" config "hostname"
port <- lookupDefault 3000 config "port" portnum <- lookupDefault 3000 config "port"
urls <- lookupDefault urlsPath config "urltable" urls <- lookupDefault urlsPath config "urltable"
cert <- lookupDefault "/usr/share/tls/breve.crt" config "tls.cert" cert <- lookupDefault "/usr/share/tls/breve.crt" config "tls.cert"
key <- lookupDefault "/usr/share/tls/breve.key" config "tls.key" key <- lookupDefault "/usr/share/tls/breve.key" config "tls.key"
chain <- lookupDefault [] config "tls.chain" chain <- lookupDefault [] config "tls.chain"
let
port = if portnum == 443 then "" else ":" <> pack (show portnum)
url = "https://" <> host <> port <> "/"
baseURL <- lookupDefault url config "baseurl"
createEmptyIfMissing urls createEmptyIfMissing urls
let base = "https://" <> host
url = if port == 443
then base
else base <> ":" <> pack (show port)
tls = (tlsSettingsChain cert chain key)
{ tlsAllowedVersions = [TLS12, TLS11]
, tlsCiphers = ciphersuite_strong
}
return AppSettings return AppSettings
{ bindHost = host { bindHost = host
, bindPort = port , bindPort = portnum
, bindUrl = url <> "/" , bindUrl = baseURL
, urlTable = urls , urlTable = urls
, tlsSettings = tls , tlsSettings = (tlsSettingsChain cert chain key)
{ tlsAllowedVersions = [TLS12, TLS11]
, tlsCiphers = ciphersuite_strong
}
} }