Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 将嵌套子目录与Scotty RoutePattern匹配_Haskell_Scotty - Fatal编程技术网

Haskell 将嵌套子目录与Scotty RoutePattern匹配

Haskell 将嵌套子目录与Scotty RoutePattern匹配,haskell,scotty,Haskell,Scotty,我正在用我的Scotty Web服务器提供一些静态文件。它们也可以位于子目录中。我目前的做法如下: get "/:fileName" $ do fileName <- param "fileName" file $ pathToStaticFiles </> fileName get "/:dirName/:fileName" $ do dirName <- param "dirName" fileName <- param "fi

我正在用我的Scotty Web服务器提供一些静态文件。它们也可以位于子目录中。我目前的做法如下:

get "/:fileName" $ do
    fileName <- param "fileName"
    file $ pathToStaticFiles </> fileName

get "/:dirName/:fileName" $ do
    dirName <- param "dirName"
    fileName <- param "fileName"
    file $ pathToStaticFiles </> dirName </> fileName

get "/:dirName1/:dirName2/:fileName" $ do
    dirName1 <- param "dirName1"
    dirName2 <- param "dirName2"
    fileName <- param "fileName"
    file $ pathToStaticFiles </> dirName1 </> dirName2 </> fileName

....
get/:fileName“$do

fileNameScotty在默认路由模式(称为
capture
)的基础上还有其他几种路由模式。这些可以在中找到

regex
似乎正是您想要的。以下是文档中的示例:

get (regex "^/f(.*)r$") $ do
   path <- param "0"
   cap <- param "1"
   text $ mconcat ["Path: ", path, "\nCapture: ", cap]
get(regex)^/f(.*)r$”$do
路径