0

给定一个像这样的 url http://test.com/abc/xyz/1/2/3,我怎样才能检索所有的 URL 段,abc/所以结果值会是["xyz","1","2","3]

4

1 回答 1

0

如果将来有人偶然发现此问题,我已设法通过以下方式解决它:

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
于 2017-03-25T17:32:56.023 回答