From 0f41ec16f14b0dbc26f633a01c3cbbcd0dbda75e Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 23 Jul 2021 23:54:43 +0100 Subject: (Server)~abstract headers into seperate constant Instead of repeating it for every new route, just set as a constant. --- Server/Main.hs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Server') diff --git a/Server/Main.hs b/Server/Main.hs index 8954d6d..bed3f82 100644 --- a/Server/Main.hs +++ b/Server/Main.hs @@ -8,6 +8,9 @@ import Network.Wai import Network.HTTP.Types import Network.Wai.Handler.Warp (run) +headers :: ResponseHeaders +headers = [("Content-Type", "text/html;charset=UTF-8")] + app :: Application app request respond = respond $ case rawPathInfo request of @@ -17,7 +20,7 @@ app request respond = respond $ index :: Response index = responseFile status200 - [("Content-Type", "text/html;charset=UTF-8")] + headers "pages/index.html" Nothing @@ -28,7 +31,7 @@ index = errorResponse :: Response errorResponse = responseFile status200 - [("Content-Type", "text/html;charset=UTF-8")] + headers "pages/error.html" Nothing -- cgit v1.2.3-13-gbd6f