mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-27 21:29:55 +03:00
Rename module.
This commit is contained in:
parent
18c2030101
commit
7b743cf72d
@ -10,8 +10,8 @@ import OptimizedDecoder as Decode
|
||||
import Route exposing (Route)
|
||||
import Secrets
|
||||
import Server.Request
|
||||
import Server.Response
|
||||
import Server.SetCookie as SetCookie
|
||||
import ServerResponse
|
||||
|
||||
|
||||
routes :
|
||||
@ -40,16 +40,16 @@ jsonError =
|
||||
(\result ->
|
||||
case result of
|
||||
Ok firstName ->
|
||||
ServerResponse.stringBody
|
||||
Server.Response.stringBody
|
||||
("Hello " ++ firstName)
|
||||
|
||||
Err decodeError ->
|
||||
decodeError
|
||||
|> Json.Decode.errorToString
|
||||
|> ServerResponse.stringBody
|
||||
|> ServerResponse.withStatusCode 400
|
||||
|> Server.Response.stringBody
|
||||
|> Server.Response.withStatusCode 400
|
||||
)
|
||||
, Server.Request.succeed (ServerResponse.stringBody "Hello anonymous!")
|
||||
, Server.Request.succeed (Server.Response.stringBody "Hello anonymous!")
|
||||
]
|
||||
|> Server.Request.map DataSource.succeed
|
||||
)
|
||||
@ -76,7 +76,7 @@ greet =
|
||||
]
|
||||
|> Server.Request.map
|
||||
(\firstName ->
|
||||
ServerResponse.stringBody ("Hello " ++ firstName)
|
||||
Server.Response.stringBody ("Hello " ++ firstName)
|
||||
|> DataSource.succeed
|
||||
)
|
||||
)
|
||||
@ -95,7 +95,7 @@ fileLength =
|
||||
)
|
||||
|> Server.Request.map
|
||||
(\file ->
|
||||
ServerResponse.json
|
||||
Server.Response.json
|
||||
(Json.Encode.object
|
||||
[ ( "File name: ", Json.Encode.string file.name )
|
||||
, ( "Length", Json.Encode.int (String.length file.body) )
|
||||
@ -124,7 +124,7 @@ redirectRoute =
|
||||
ApiRoute.succeed
|
||||
(Server.Request.succeed
|
||||
(DataSource.succeed
|
||||
(ServerResponse.temporaryRedirect "/")
|
||||
(Server.Response.temporaryRedirect "/")
|
||||
)
|
||||
)
|
||||
|> ApiRoute.literal "api"
|
||||
@ -146,7 +146,7 @@ noArgs =
|
||||
[ ( "repo", Json.Encode.string "elm-pages" )
|
||||
, ( "stars", Json.Encode.int stars )
|
||||
]
|
||||
|> ServerResponse.json
|
||||
|> Server.Response.json
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -187,8 +187,8 @@ logout =
|
||||
ApiRoute.succeed
|
||||
(Server.Request.succeed
|
||||
(DataSource.succeed
|
||||
(ServerResponse.stringBody "You are logged out"
|
||||
|> ServerResponse.withHeader "Set-Cookie"
|
||||
(Server.Response.stringBody "You are logged out"
|
||||
|> Server.Response.withHeader "Set-Cookie"
|
||||
(SetCookie.setCookie "username" ""
|
||||
|> SetCookie.httpOnly
|
||||
|> SetCookie.withPath "/"
|
||||
@ -218,7 +218,7 @@ repoStars =
|
||||
[ ( "repo", Json.Encode.string repoName )
|
||||
, ( "stars", Json.Encode.int stars )
|
||||
]
|
||||
|> ServerResponse.json
|
||||
|> Server.Response.json
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -244,7 +244,7 @@ repoStars2 =
|
||||
[ ( "repo", Json.Encode.string repoName )
|
||||
, ( "stars", Json.Encode.int stars )
|
||||
]
|
||||
|> ServerResponse.json
|
||||
|> Server.Response.json
|
||||
)
|
||||
)
|
||||
|> ApiRoute.literal "api2"
|
||||
|
@ -12,7 +12,7 @@ import PageServerResponse exposing (PageServerResponse)
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Server.Request as Request
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
import Shared
|
||||
import Time
|
||||
import View exposing (View)
|
||||
@ -62,7 +62,7 @@ data routeParams =
|
||||
)
|
||||
, Request.succeed
|
||||
(DataSource.succeed
|
||||
(PageServerResponse.ServerResponse (ServerResponse.temporaryRedirect "/login"))
|
||||
(PageServerResponse.ServerResponse (Server.Response.temporaryRedirect "/login"))
|
||||
)
|
||||
]
|
||||
|
||||
|
@ -11,8 +11,8 @@ import PageServerResponse exposing (PageServerResponse)
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Server.Request as Request
|
||||
import Server.Response
|
||||
import Server.SetCookie as SetCookie
|
||||
import ServerResponse
|
||||
import Shared
|
||||
import View exposing (View)
|
||||
|
||||
@ -52,8 +52,8 @@ data routeParams =
|
||||
(\name ->
|
||||
PageServerResponse.ServerResponse
|
||||
("/greet"
|
||||
|> ServerResponse.temporaryRedirect
|
||||
|> ServerResponse.withHeader "Set-Cookie"
|
||||
|> Server.Response.temporaryRedirect
|
||||
|> Server.Response.withHeader "Set-Cookie"
|
||||
(SetCookie.setCookie "username" name
|
||||
|> SetCookie.httpOnly
|
||||
|> SetCookie.withPath "/"
|
||||
|
@ -12,7 +12,7 @@ import PageServerResponse exposing (PageServerResponse)
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Secrets
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
import Shared
|
||||
import View exposing (View)
|
||||
|
||||
@ -73,8 +73,8 @@ data { pokedexNumber } =
|
||||
|
||||
notFoundResponse : String -> DataSource (PageServerResponse Data)
|
||||
notFoundResponse message =
|
||||
ServerResponse.stringBody ("Not found.\n\n" ++ message)
|
||||
|> ServerResponse.withStatusCode 404
|
||||
Server.Response.stringBody ("Not found.\n\n" ++ message)
|
||||
|> Server.Response.withStatusCode 404
|
||||
|> PageServerResponse.ServerResponse
|
||||
|> DataSource.succeed
|
||||
|
||||
|
@ -12,7 +12,7 @@ import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Route
|
||||
import Server.Request as Request
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
import Shared
|
||||
import View exposing (View)
|
||||
|
||||
|
@ -10,7 +10,7 @@ import PageServerResponse exposing (PageServerResponse)
|
||||
import Pages.PageUrl exposing (PageUrl)
|
||||
import Pages.Url
|
||||
import Server.Request as Request
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
import Shared
|
||||
import Url
|
||||
import View exposing (View)
|
||||
@ -98,7 +98,7 @@ data routeParams =
|
||||
Request.succeed ()
|
||||
|> Request.map
|
||||
(\() ->
|
||||
PageServerResponse.ServerResponse (ServerResponse.stringBody "Hello, this is a string")
|
||||
PageServerResponse.ServerResponse (Server.Response.stringBody "Hello, this is a string")
|
||||
|> DataSource.succeed
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ import Pages.StaticHttpRequest as StaticHttpRequest
|
||||
import Path exposing (Path)
|
||||
import RenderRequest exposing (RenderRequest)
|
||||
import SecretsDict exposing (SecretsDict)
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
import Task
|
||||
import TerminalText as Terminal
|
||||
import Url
|
||||
@ -826,7 +826,7 @@ nextStepToEffect site contentCache config model ( updatedStaticResponsesModel, n
|
||||
|> Effect.SendSinglePage False
|
||||
|
||||
PageServerResponse.ServerResponse serverResponse ->
|
||||
{ body = serverResponse |> ServerResponse.toJson
|
||||
{ body = serverResponse |> Server.Response.toJson
|
||||
, staticHttpCache = model.allRawResponses |> Dict.Extra.filterMap (\_ v -> v)
|
||||
, statusCode = 200
|
||||
}
|
||||
@ -997,7 +997,7 @@ sendSinglePageProgress site contentJson config model =
|
||||
|> Effect.SendSinglePage True
|
||||
|
||||
PageServerResponse.ServerResponse serverResponse ->
|
||||
{ body = serverResponse |> ServerResponse.toJson
|
||||
{ body = serverResponse |> Server.Response.toJson
|
||||
, staticHttpCache = model.allRawResponses |> Dict.Extra.filterMap (\_ v -> v)
|
||||
, statusCode = 200
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ import Pattern exposing (Pattern)
|
||||
import Regex
|
||||
import Secrets
|
||||
import Server.Request
|
||||
import ServerResponse
|
||||
import Server.Response
|
||||
|
||||
|
||||
{-| -}
|
||||
@ -84,7 +84,7 @@ stripTrailingSlash path =
|
||||
|
||||
|
||||
{-| -}
|
||||
serverRender : ApiRouteBuilder (Server.Request.Request (DataSource ServerResponse.Response)) constructor -> ApiRoute Response
|
||||
serverRender : ApiRouteBuilder (Server.Request.Request (DataSource Server.Response.Response)) constructor -> ApiRoute Response
|
||||
serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
ApiRoute
|
||||
{ regex = Regex.fromString ("^" ++ pattern ++ "$") |> Maybe.withDefault Regex.never
|
||||
@ -108,17 +108,17 @@ serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullH
|
||||
Just (Err errors) ->
|
||||
errors
|
||||
|> Server.Request.errorsToString
|
||||
|> ServerResponse.stringBody
|
||||
|> ServerResponse.withStatusCode 400
|
||||
|> Server.Response.stringBody
|
||||
|> Server.Response.withStatusCode 400
|
||||
|> DataSource.succeed
|
||||
|
||||
Nothing ->
|
||||
ServerResponse.stringBody "No matching request handler"
|
||||
|> ServerResponse.withStatusCode 400
|
||||
Server.Response.stringBody "No matching request handler"
|
||||
|> Server.Response.withStatusCode 400
|
||||
|> DataSource.succeed
|
||||
)
|
||||
)
|
||||
|> Maybe.map (DataSource.map (ServerResponse.toJson >> Just))
|
||||
|> Maybe.map (DataSource.map (Server.Response.toJson >> Just))
|
||||
|> Maybe.withDefault
|
||||
(DataSource.succeed Nothing)
|
||||
, buildTimeRoutes = DataSource.succeed []
|
||||
@ -138,7 +138,7 @@ serverRender ((ApiRouteBuilder patterns pattern _ toString constructor) as fullH
|
||||
|
||||
|
||||
{-| -}
|
||||
preRenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource ServerResponse.Response) constructor -> ApiRoute Response
|
||||
preRenderWithFallback : (constructor -> DataSource (List (List String))) -> ApiRouteBuilder (DataSource Server.Response.Response) constructor -> ApiRoute Response
|
||||
preRenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString constructor) as fullHandler) =
|
||||
let
|
||||
buildTimeRoutes__ : DataSource (List String)
|
||||
@ -155,7 +155,7 @@ preRenderWithFallback buildUrls ((ApiRouteBuilder patterns pattern _ toString co
|
||||
, matchesToResponse =
|
||||
\path ->
|
||||
Internal.ApiRoute.tryMatch path fullHandler
|
||||
|> Maybe.map (DataSource.map (ServerResponse.toJson >> Just))
|
||||
|> Maybe.map (DataSource.map (Server.Response.toJson >> Just))
|
||||
|> Maybe.withDefault
|
||||
(DataSource.succeed Nothing)
|
||||
, buildTimeRoutes = buildTimeRoutes__
|
||||
|
@ -6,7 +6,7 @@ module PageServerResponse exposing (map, PageServerResponse(..))
|
||||
|
||||
-}
|
||||
|
||||
import ServerResponse exposing (Response)
|
||||
import Server.Response exposing (Response)
|
||||
|
||||
|
||||
{-| -}
|
||||
|
@ -1,4 +1,4 @@
|
||||
module ServerResponse exposing (Response, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode)
|
||||
module Server.Response exposing (Response, json, permanentRedirect, stringBody, success, temporaryRedirect, toJson, withHeader, withStatusCode)
|
||||
|
||||
{-|
|
||||
|
Loading…
Reference in New Issue
Block a user