如何通过Haskell Scotty获得每条路线?
问题描述:
我有一个简单的服务器如何通过Haskell Scotty获得每条路线?
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Data.Text
import Data.Monoid (mconcat)
server :: ScottyM()
server = do
get "/" $ file "./index.html"
,我想对所有的航线如服务index.html
。 get "*" $ file "./index.html"
,但这不起作用。如何实现这一目标?
答
同在所提供的例子: https://github.com/scotty-web/scotty
{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import Data.Monoid (mconcat)
main = scotty 3000 $
get "/:word" $ do
file "./index.html"
但是'''得到 “/:单词”'''会返回 '找不到文件' 当第二参数是与像''provieded 'HTTP://hostip.com/:字/:second_param'''。我需要得到“*”。我知道haskell和scotty在其RoutePatterns中支持正则表达式,但不知道正则表达式,socotty正则表达式是如何工作的以及它如何将String转换为RoutePattern类型 – F1ks3r