@@ -558,9 +558,9 @@ instance (KnownSymbol sym, HasServer api context)
558
558
examine v | v == " true" || v == " 1" || v == " " = True
559
559
| otherwise = False
560
560
561
- -- | If you define a custom record type, for example @BookSearchParams@, then you can use
562
- -- @'QueryParamForm' "formName" BookSearchParams@ in one of the endpoints for your API
563
- -- to translate a collection of query-string parameters into a value of your record type.
561
+ -- | If you define a custom record type, for example @BookSearchParams@, then you can use
562
+ -- @'QueryParamForm' BookSearchParams@ in one of the endpoints for your API
563
+ -- to translate a collection of query-string parameters into a value of your record type.
564
564
--
565
565
-- Your server-side handler must be a function that takes an argument of type
566
566
-- @'Maybe' ('Either' BookSearchParams)@.
@@ -582,26 +582,24 @@ instance (KnownSymbol sym, HasServer api context)
582
582
-- > , page :: Maybe Int
583
583
-- > } deriving (Eq, Show, Generic)
584
584
-- > instance FromForm BookSearchParams
585
- -- > type MyApi = "books" :> QueryParamForm "searchQ" BookSearchParams :> Get '[JSON] [Book]
586
- --
585
+ -- > type MyApi = "books" :> QueryParamForm BookSearchParams :> Get '[JSON] [Book]
586
+ --
587
587
-- Example Handler Signature:
588
588
-- Maybe (Either Text BookSearchParams) -> Handler [Book]
589
589
instance
590
- ( KnownSymbol sym , FromForm a , HasServer api context
590
+ (FromForm a , HasServer api context
591
591
, SBoolI (FoldRequired mods ), SBoolI (FoldLenient mods )
592
592
)
593
- => HasServer (QueryParamForm' mods sym a :> api ) context where
593
+ => HasServer (QueryParamForm' mods a :> api ) context where
594
594
------
595
- type ServerT (QueryParamForm' mods sym a :> api ) m =
595
+ type ServerT (QueryParamForm' mods a :> api ) m =
596
596
RequestArgument mods a -> ServerT api m
597
597
598
598
hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy :: Proxy api ) pc nt . s
599
599
600
- route Proxy context subserver =
601
-
602
- let formName = cs $ symbolVal (Proxy :: Proxy sym )
600
+ route Proxy context subserver =
603
601
604
- parseParamForm req =
602
+ let parseParamForm req =
605
603
unfoldRequestArgument (Proxy :: Proxy mods ) errReq errSt mev
606
604
where
607
605
rawQS = rawQueryString req
@@ -612,12 +610,11 @@ instance
612
610
_ -> Just $ urlDecodeAsForm (BL. drop 1 . BL. fromStrict $ rawQS)
613
611
614
612
errReq = delayedFailFatal err400
615
- { errBody = cs $ " Query parameter form " <> formName <> " is required"
613
+ { errBody = " Query parameter form is required"
616
614
}
617
615
618
616
errSt e = delayedFailFatal err400
619
- { errBody = cs $ " Error parsing query parameter form "
620
- <> formName <> " failed: " <> e
617
+ { errBody = cs $ " Error: parsing query parameter form failed. " <> e
621
618
}
622
619
623
620
delayed = addParameterCheck subserver . withRequest $ \ req ->
0 commit comments