是否可以使用 Template Haskell 或任何其他方式在编译时通过配置文件动态添加路由。
Scotty 有一个函数addRoute但我想动态使用它。
例子
import qualified Data.Text.Lazy as LTB
sampleRoutes :: [(String, LTB.Text)]
sampleRoutes = [("hello", LTB.pack "hello"), ("world", LTB.pack "world")]
我想遍历 sampleRoutes 数组并在编译时定义路由和响应。
import Web.Scotty
main = scotty 3000 $ do
middleware logStdoutDev
someFunc sampleRoutes