Hello,

I have difficulties mixing web-routes and forms:
I have put routes in all my site, except for forms which remains with the
type ServerPartT IO Response.
How to make them work together?

I have:
type NomicServer             = ServerPartT IO
type RoutedNomicServer = RouteT PlayerCommand NomicServer

newRule :: ServerHandle -> NomicServer Response
newRule sh = do
   methodM POST -- only accept a post method
   mbEntry <- getData -- get the data
   case mbEntry of
      Nothing -> error $ "error: newRule"
      Just (NewRule name text code pn) -> do
         *html <- nomicPageComm pn sh (submitRule name text code pn))*
         ok $ toResponse html


nomicPageComm :: PlayerNumber -> ServerHandle -> Comm () ->
RoutedNomicServer Html
nomicPageComm pn sh comm =
(..)


launchWebServer :: ServerHandle -> IO ()
launchWebServer sh = do
   putStrLn "Starting web server...\nTo connect, drive your browser to \"
http://localhost:8000/Login\"";
   d <- liftIO getDataDir
   simpleHTTP nullConf $ mconcat [dir "postLogin" $ postLogin,
                                  fileServe [] d,
                                  dir "Login" $ ok $ toResponse $ loginPage,
                                  dir "NewRule" $ newRule sh,
                                  dir "NewGame" $ newGameWeb sh,
                                  dir "Nomic" $ do
                                     html <- implSite "
http://localhost:8000/Nomic/"; "" (nomicSite sh)
                                     ok $ toResponse html
                                  ]


The red line doesn't compile. I don't know how to transform a
RoutedNomicServer into a NomicServer.

For the future I intend to use formlets: is these some examples of programs
using happstack + web-routes + formlets?

Thanks,
Corentin




On Fri, Jan 7, 2011 at 5:10 PM, Jeremy Shaw <jer...@n-heptane.com> wrote:

> Hello,
>
> The [(String, String)] argument is for adding query parameters.
>
> > encodePathInfo ["foo", "bar", "baz"] [("key","value")]
>
> "foo/bar/baz?key=value"
>
> Instead of showURL you would use showURLParams.
>
> hope this helps!d
> - jeremy
>
> On Fri, Jan 7, 2011 at 8:12 AM, Corentin Dupont
> <corentin.dup...@gmail.com> wrote:
> > Hello Jeremy,
> > I'm using Web routes with happstack.
> > I'm following this tutorial:
> > http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html
> >
> > But It seems out of synch with the latest version of web-routes: 0.23.2.
> > The haddock documentation seems out of date also:
> >
> > encodePathInfo :: [String] -> [(String, String)] -> String
> >
> > For example:
> >
> >  encodePathInfo [\"foo\", \"bar\", \"baz\"]
> >
> > "foo/bar/baz"
> >
> > And I can't figure out what this [(String, String)] is for ;)
> >
> > Thanks,
> >
> > Corentin
> >
>
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to