Reputation: 11
i am not sure if i should use eval
for this but i want to dynamically load the routes in a SnapFramework
from a csv
file, like this:
csv file
route, file
redirect, redirects.csv
red, redirects2.csv
Now, i want to say to the framework which file should read in which ocasion
hs file
start = do
snapRoutes <- readCsv "routes.csv"
rut a = ((fst a ++ "/:md5"), redirectTo (snd a))
skite :: Snap ()
skite =
ifTop noHandler <|>
route (mapM_ rut start) <|>
fourOhFour
Now i want to inject the following Snap monad
in the tuple
needed for routes and it seems i can't figure out how. Can liftM
or unsafeEval
solve the problem? And how?
redirectTo :: String -> Snap()
redirectTo fileName = do
param <- getParam "md5"
redirects <- liftIO $ readCsv fileName
theParam <- maybe (return "oh no")
return param
writeBS redirects
Or any other ideas?
Thanks :)
Upvotes: 1
Views: 43