Skip to content

Commit 2851468

Browse files
committed
Move body type to endpoint type
1 parent 7bab5d5 commit 2851468

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Servant/To/Elm.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ elmEndpointDefinition urlBase moduleName endpoint =
9090
| (_, type_, arg) <- _queryString $ _url endpoint
9191
]
9292
, [ _encodedType body
93-
| Just body <- [_body endpoint]
93+
| Just (_, body) <- [_body endpoint]
9494
]
9595
]
9696
)
@@ -286,9 +286,9 @@ elmEndpointDefinition urlBase moduleName endpoint =
286286
Nothing ->
287287
"Http.emptyBody"
288288

289-
Just body ->
289+
Just (bodyType, body) ->
290290
Expression.App
291-
"Http.jsonBody"
291+
(vacuous bodyType)
292292
(Expression.App (vacuous $ _encoder body) $ pure bodyArgName)
293293

294294
elmExpect =
@@ -402,7 +402,7 @@ data Endpoint = Endpoint
402402
{ _url :: URL
403403
, _method :: HTTP.Method
404404
, _headers :: [(Text, Encoder, Bool)]
405-
, _body :: Maybe Encoder
405+
, _body :: Maybe (Expression Void, Encoder)
406406
, _returnType :: Maybe Decoder
407407
, _functionName :: [Text]
408408
}
@@ -561,7 +561,7 @@ instance (HasElmEncoder Aeson.Value a, HasElmEndpoints api, list ~ '[Servant.JSO
561561
=> HasElmEndpoints (Servant.ReqBody' mods list a :> api) where
562562
elmEndpoints' prefix =
563563
elmEndpoints' @api prefix
564-
{ _body = Just $ makeEncoder @Aeson.Value @a
564+
{ _body = Just ("Http.jsonBody", makeEncoder @Aeson.Value @a)
565565
}
566566

567567
instance (KnownSymbol path, HasElmEndpoints api) => HasElmEndpoints (path :> api) where

0 commit comments

Comments
 (0)