use queryString not rawQueryString, enables param rewrites with Middleware possible
This commit is contained in:
parent
b4e5aa0def
commit
28c4533659
1 changed files with 5 additions and 5 deletions
|
@ -64,7 +64,7 @@ import Network.Socket
|
||||||
(SockAddr)
|
(SockAddr)
|
||||||
import Network.Wai
|
import Network.Wai
|
||||||
(Application, Request, httpVersion, isSecure, lazyRequestBody,
|
(Application, Request, httpVersion, isSecure, lazyRequestBody,
|
||||||
rawQueryString, remoteHost, requestBody, requestHeaders,
|
queryString, remoteHost, requestBody, requestHeaders,
|
||||||
requestMethod, responseLBS, responseStream, vault)
|
requestMethod, responseLBS, responseStream, vault)
|
||||||
import Prelude ()
|
import Prelude ()
|
||||||
import Prelude.Compat
|
import Prelude.Compat
|
||||||
|
@ -452,7 +452,7 @@ instance
|
||||||
hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy :: Proxy api) pc nt . s
|
hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy :: Proxy api) pc nt . s
|
||||||
|
|
||||||
route Proxy context subserver =
|
route Proxy context subserver =
|
||||||
let querytext req = parseQueryText $ rawQueryString req
|
let querytext = queryToQueryText . queryString
|
||||||
paramname = cs $ symbolVal (Proxy :: Proxy sym)
|
paramname = cs $ symbolVal (Proxy :: Proxy sym)
|
||||||
|
|
||||||
parseParam :: Request -> DelayedIO (RequestArgument mods a)
|
parseParam :: Request -> DelayedIO (RequestArgument mods a)
|
||||||
|
@ -519,8 +519,8 @@ instance (KnownSymbol sym, FromHttpApiData a, HasServer api context)
|
||||||
params :: [T.Text]
|
params :: [T.Text]
|
||||||
params = mapMaybe snd
|
params = mapMaybe snd
|
||||||
. filter (looksLikeParam . fst)
|
. filter (looksLikeParam . fst)
|
||||||
. parseQueryText
|
. queryToQueryText
|
||||||
. rawQueryString
|
. queryString
|
||||||
$ req
|
$ req
|
||||||
|
|
||||||
looksLikeParam name = name == paramname || name == (paramname <> "[]")
|
looksLikeParam name = name == paramname || name == (paramname <> "[]")
|
||||||
|
@ -546,7 +546,7 @@ instance (KnownSymbol sym, HasServer api context)
|
||||||
hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy :: Proxy api) pc nt . s
|
hoistServerWithContext _ pc nt s = hoistServerWithContext (Proxy :: Proxy api) pc nt . s
|
||||||
|
|
||||||
route Proxy context subserver =
|
route Proxy context subserver =
|
||||||
let querytext r = parseQueryText $ rawQueryString r
|
let querytext = queryToQueryText . queryString
|
||||||
param r = case lookup paramname (querytext r) of
|
param r = case lookup paramname (querytext r) of
|
||||||
Just Nothing -> True -- param is there, with no value
|
Just Nothing -> True -- param is there, with no value
|
||||||
Just (Just v) -> examine v -- param with a value
|
Just (Just v) -> examine v -- param with a value
|
||||||
|
|
Loading…
Reference in a new issue