2017-10-20 39 views
0

我有一個簡單的服務器如何通過Haskell Scotty獲得每條路線?

{-# LANGUAGE OverloadedStrings #-} 

import Web.Scotty 
import Data.Text 
import Data.Monoid (mconcat) 

server :: ScottyM() 
server = do 
    get "/" $ file "./index.html" 

,我想對所有的航線如服務index.htmlget "*" $ file "./index.html",但這不起作用。如何實現這一目標?

回答

0

同在所提供的例子: https://github.com/scotty-web/scotty

{-# LANGUAGE OverloadedStrings #-} 
import Web.Scotty 
import Data.Monoid (mconcat) 

main = scotty 3000 $ 
    get "/:word" $ do 
     file "./index.html" 
+0

但是'''得到 「/:單詞」'''會返回 '找不到文件' 當第二參數是與像''provieded 'HTTP://hostip.com/:字/:second_param'''。我需要得到「*」。我知道haskell和scotty在其RoutePatterns中支持正則表達式,但不知道正則表達式,socotty正則表達式是如何工作的以及它如何將String轉換爲RoutePattern類型 – F1ks3r