【发布时间】:2017-03-25 17:30:39
【问题描述】:
给定一个像http://test.com/abc/xyz/1/2/3 这样的网址,我如何检索abc/ 之后的所有网址段,所以结果值将是["xyz","1","2","3]?
【问题讨论】:
标签: scotty haskell-wai
给定一个像http://test.com/abc/xyz/1/2/3 这样的网址,我如何检索abc/ 之后的所有网址段,所以结果值将是["xyz","1","2","3]?
【问题讨论】:
标签: scotty haskell-wai
如果将来有人偶然发现这个问题,我已经设法解决它:
processParams :: String -> Request -> Maybe [Param]
processParams s x = do
case (params', isPrefix) of
(_:paramsxs, True) -> return $ fmap (flip (,) $ "") paramsxs
_ -> Nothing
where
isPrefix = s `isPrefixOf` (convertString path) :: Bool
path = rawPathInfo x
params' = fmap convertString $ decodePathSegments path
并使用function 函数:
get (function $ processParams "/comparePackage") $ comparePackageHandler
【讨论】: