@@ -27,6 +27,7 @@ import Control.Monad.Base (MonadBase (..))
2727import Control.Monad.IO.Class ()
2828import Control.Monad.Reader
2929import Control.Monad.Trans.Control (MonadBaseControl (..))
30+import qualified Data.ByteString.Builder as BS
3031import Data.ByteString.Lazy hiding (pack, filter, map, null, elem, any)
3132import Data.String
3233import Data.String.Conversions (cs)
@@ -86,7 +87,7 @@ instance Eq ServantError where
8687instance Exception ServantError
8788
8889data Req = Req
89− { reqPath :: String
90+ { reqPath :: BS.Builder
9091 , qs :: QueryText
9192 , reqBody :: Maybe (RequestBody, MediaType)
9293 , reqAccept :: [MediaType]
@@ -98,7 +99,7 @@ defReq = Req "" [] Nothing [] []
9899
99100appendToPath :: String -> Req -> Req
100101appendToPath p req =
101− req { reqPath = reqPath req ++ "/" ++ p }
102+ req { reqPath = reqPath req <> "/" <> toEncodedUrlPiece p }
102103
103104appendToQueryString :: Text -- ^ param name
104105 -> Maybe Text -- ^ param value
@@ -151,8 +152,9 @@ reqToRequest req (BaseUrl reqScheme reqHost reqPort path) =
151152 , uriRegName = reqHost
152153 , uriPort = ":" ++ show reqPort
153154 }
154− , uriPath = path ++ reqPath req
155+ , uriPath = fullPath
155156 }
157+ fullPath = path ++ cs (BS.toLazyByteString (reqPath req))
156158
157159 setrqb r = case reqBody req of
158160 Nothing -> r