X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FDefaultPage.hs;h=8f19d8968d9d50fd2c8e5f8b12c936f74de4f172;hb=243b99439640480fc148d2e175247dacce04a222;hp=d95291764cf2ecd7c1b4c0e8beebe84a1f20744c;hpb=bb41be0c967538a1014c87103a3a5d3840ad3e15;p=Lucu.git diff --git a/Network/HTTP/Lucu/DefaultPage.hs b/Network/HTTP/Lucu/DefaultPage.hs index d952917..8f19d89 100644 --- a/Network/HTTP/Lucu/DefaultPage.hs +++ b/Network/HTTP/Lucu/DefaultPage.hs @@ -13,8 +13,8 @@ module Network.HTTP.Lucu.DefaultPage where import Blaze.ByteString.Builder (Builder) import Data.Ascii (Ascii) -import qualified Data.Ascii as A import qualified Data.CaseInsensitive as CI +import Data.Convertible.Base import Data.Convertible.Utils import Data.Maybe import Data.Monoid.Unicode @@ -23,6 +23,7 @@ import Network.HTTP.Lucu.Config import Network.HTTP.Lucu.Headers import Network.HTTP.Lucu.Request import Network.HTTP.Lucu.Response +import Network.HTTP.Lucu.Response.StatusCode import Network.URI hiding (path) import Prelude hiding (head) import Prelude.Unicode @@ -52,7 +53,7 @@ defaultPageWithMessage (Config {..}) sc msg body $ do h1 status p msg hr - address $ do toHtml $ A.toText cnfServerSoftware + address $ do toHtml (cs cnfServerSoftware ∷ Text) unsafeByteString " at " toHtml $ CI.original cnfServerHost where @@ -65,28 +66,28 @@ defaultMessage req res@(Response {..}) -- 1xx responses don't have a body. -- 2xx responses don't need a body to be completed. -- 3xx: - | resStatus ≈ MovedPermanently + | resStatus ≡ cs MovedPermanently = do unsafeByteString "The resource at " path unsafeByteString " has been moved to " a ! href (toValue loc) $ toHtml loc unsafeByteString " permanently." - | resStatus ≈ Found + | resStatus ≡ cs Found = do unsafeByteString "The resource at " path unsafeByteString " is currently located at " a ! href (toValue loc) $ toHtml loc unsafeByteString ". This is not a permanent relocation." - | resStatus ≈ SeeOther + | resStatus ≡ cs SeeOther = do unsafeByteString "The resource at " path unsafeByteString " can be found at " a ! href (toValue loc) $ toHtml loc unsafeByteString "." - | resStatus ≈ TemporaryRedirect + | resStatus ≡ cs TemporaryRedirect = do unsafeByteString "The resource at " path unsafeByteString " is temporarily located at " @@ -94,31 +95,31 @@ defaultMessage req res@(Response {..}) unsafeByteString "." -- 4xx: - | resStatus ≈ BadRequest + | resStatus ≡ cs BadRequest = unsafeByteString "The server could not understand the request you sent." - | resStatus ≈ Unauthorized + | resStatus ≡ cs Unauthorized = unsafeByteString "You need a valid authentication to access " ⊕ path - | resStatus ≈ Forbidden + | resStatus ≡ cs Forbidden = unsafeByteString "You don't have permission to access " ⊕ path - | resStatus ≈ NotFound + | resStatus ≡ cs NotFound = do unsafeByteString "The requested URL " path unsafeByteString " was not found on this server." - | resStatus ≈ Gone + | resStatus ≡ cs Gone = do unsafeByteString "The resource at " path unsafeByteString " was here in past times, but has gone permanently." - | resStatus ≈ RequestEntityTooLarge + | resStatus ≡ cs RequestEntityTooLarge = do unsafeByteString "The request entity you sent for " path unsafeByteString " was too large to accept." - | resStatus ≈ RequestURITooLarge + | resStatus ≡ cs RequestURITooLarge = unsafeByteString "The request URI you sent was too large to accept." -- 5xx: - | resStatus ≈ InternalServerError + | resStatus ≡ cs InternalServerError = unsafeByteString "An internal server error has occured during the process of your request to " ⊕ path - | resStatus ≈ ServiceUnavailable + | resStatus ≡ cs ServiceUnavailable = unsafeByteString "The service is temporarily unavailable. Try later." | otherwise @@ -128,7 +129,7 @@ defaultMessage req res@(Response {..}) path = toHtml ∘ uriPath ∘ reqURI $ fromJust req loc ∷ Text - loc = A.toText ∘ fromJust $ getHeader "Location" res + loc = cs ∘ fromJust $ getHeader "Location" res hr ∷ Html {-# INLINE hr #-}