diff --git a/src/Application.hs b/src/Application.hs index 6529625..1d6f139 100644 --- a/src/Application.hs +++ b/src/Application.hs @@ -67,3 +67,10 @@ app url' table = do json $ object [ "link" .= (url' <> name) , "name" .= name , "original" .= url ] + + +toTLS :: Text -> SpockT IO () +toTLS host = do + get var (redirect . new) + get "/" (redirect $ new "") + where new url = "https://" <> host <> "/" <> url \ No newline at end of file diff --git a/src/Breve/Settings.hs b/src/Breve/Settings.hs index 72e73a5..9b4808a 100644 --- a/src/Breve/Settings.hs +++ b/src/Breve/Settings.hs @@ -45,7 +45,8 @@ settings = do else base <> ":" <> pack (show port) return AppSettings - { bindPort = port + { bindHost = host + , bindPort = port , bindUrl = url <> "/" , urlTable = urls , tlsSetts = tlsSettings cert key diff --git a/src/Main.hs b/src/Main.hs index 2f35bd1..2fa70cc 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -31,7 +31,7 @@ main = do AppSettings {..} <- settings table <- load urlTable - putStrLn ("Serving on " ++ unpack bindUrl) - when (bindPort == 443) (forkIO' $ runTLSRedirect bindHost) + + putStrLn ("Serving on " ++ unpack bindUrl) runBreve tlsSetts bindPort (app bindUrl table) \ No newline at end of file