Rename type.

This commit is contained in:
Dillon Kearns 2021-12-31 16:10:45 -08:00
parent 86142cb6d8
commit 18c2030101
3 changed files with 16 additions and 16 deletions

View File

@ -43,7 +43,7 @@ import Pattern exposing (Pattern)
import Regex
import Secrets
import Server.Request
import ServerResponse exposing (ServerResponse)
import ServerResponse
{-| -}
@ -84,7 +84,7 @@ stripTrailingSlash path =
{-| -}
serverRender : ApiRouteBuilder (Server.Request.Request (DataSource ServerResponse)) constructor -> ApiRoute Response
serverRender : ApiRouteBuilder (Server.Request.Request (DataSource ServerResponse.Response)) constructor -> ApiRoute Response
serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
ApiRoute
{ regex = Regex.fromString ("^" ++ pattern ++ "$") |> Maybe.withDefault Regex.never
@ -138,7 +138,7 @@ serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullH
{-| -}
preRenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource ServerResponse) constructor -> ApiRoute Response
preRenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource ServerResponse.Response) constructor -> ApiRoute Response
preRenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
let
buildTimeRoutes__ : DataSource (List String)

View File

@ -6,13 +6,13 @@ module PageServerResponse exposing (map, PageServerResponse(..))
-}
import ServerResponse exposing (ServerResponse)
import ServerResponse exposing (Response)
{-| -}
type PageServerResponse data
= RenderPage data
| ServerResponse ServerResponse
| ServerResponse Response
{-| -}

View File

@ -1,8 +1,8 @@
module ServerResponse exposing (ServerResponse, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode)
module ServerResponse exposing (Response, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode)
{-|
@docs ServerResponse, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode
@docs Response, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode
-}
@ -11,7 +11,7 @@ import List.Extra
{-| -}
type alias ServerResponse =
type alias Response =
{ statusCode : Int
, headers : List ( String, String )
, body : Maybe String
@ -20,7 +20,7 @@ type alias ServerResponse =
{-| -}
stringBody : String -> ServerResponse
stringBody : String -> Response
stringBody string =
{ statusCode = 200
, headers = [ ( "Content-Type", "text/plain" ) ]
@ -30,7 +30,7 @@ stringBody string =
{-| -}
success : ServerResponse
success : Response
success =
{ statusCode = 200
, headers = []
@ -40,7 +40,7 @@ success =
{-| -}
json : Json.Encode.Value -> ServerResponse
json : Json.Encode.Value -> Response
json jsonValue =
{ statusCode = 200
, headers =
@ -55,7 +55,7 @@ json jsonValue =
{-| -}
permanentRedirect : String -> ServerResponse
permanentRedirect : String -> Response
permanentRedirect url =
{ body = Nothing
, statusCode = 308
@ -67,7 +67,7 @@ permanentRedirect url =
{-| -}
temporaryRedirect : String -> ServerResponse
temporaryRedirect : String -> Response
temporaryRedirect url =
{ body = Nothing
, statusCode = 307
@ -79,19 +79,19 @@ temporaryRedirect url =
{-| -}
withStatusCode : Int -> ServerResponse -> ServerResponse
withStatusCode : Int -> Response -> Response
withStatusCode statusCode serverResponse =
{ serverResponse | statusCode = statusCode }
{-| -}
withHeader : String -> String -> ServerResponse -> ServerResponse
withHeader : String -> String -> Response -> Response
withHeader name value serverResponse =
{ serverResponse | headers = ( name, value ) :: serverResponse.headers }
{-| -}
toJson : ServerResponse -> Json.Encode.Value
toJson : Response -> Json.Encode.Value
toJson serverResponse =
Json.Encode.object
[ ( "body", serverResponse.body |> Maybe.map Json.Encode.string |> Maybe.withDefault Json.Encode.null )