Hello,<br><br>I have difficulties mixing web-routes and forms:<br>I have put routes in all my site, except for forms which remains with the type ServerPartT IO Response.<br>How to make them work together?<br><br>I have:<br>
<span style="font-family: courier new,monospace;">type NomicServer             = ServerPartT IO</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">type RoutedNomicServer = RouteT PlayerCommand NomicServer</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">newRule :: ServerHandle -&gt; NomicServer Response</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">newRule sh = do</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   methodM POST -- only accept a post method</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   mbEntry &lt;- getData -- get the data</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   case mbEntry of</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">      Nothing -&gt; error $ &quot;error: newRule&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">      Just (NewRule name text code pn) -&gt; do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         </span><i style="color: rgb(255, 0, 0); font-family: courier new,monospace;"><b>html &lt;- nomicPageComm pn sh (submitRule name text code pn))</b></i><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">         ok $ toResponse html</span><br style="font-family: courier new,monospace;"><br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">nomicPageComm :: PlayerNumber -&gt; ServerHandle -&gt; Comm () -&gt; RoutedNomicServer Html</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">nomicPageComm pn sh comm =</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(..)</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">launchWebServer :: ServerHandle -&gt; IO ()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">launchWebServer sh = do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   putStrLn &quot;Starting web server...\nTo connect, drive your browser to \&quot;<a href="http://localhost:8000/Login\">http://localhost:8000/Login\</a>&quot;&quot;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">   d &lt;- liftIO getDataDir</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">   simpleHTTP nullConf $ mconcat [dir &quot;postLogin&quot; $ postLogin,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                  fileServe [] d,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                  dir &quot;Login&quot; $ ok $ toResponse $ loginPage,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                  dir &quot;NewRule&quot; $ newRule sh,</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                  dir &quot;NewGame&quot; $ newGameWeb sh,</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                  dir &quot;Nomic&quot; $ do</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                     html &lt;- implSite &quot;<a href="http://localhost:8000/Nomic/">http://localhost:8000/Nomic/</a>&quot; &quot;&quot; (nomicSite sh)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">                                     ok $ toResponse html</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">                                  ]</span><br>
<br><br>The red line doesn&#39;t compile. I don&#39;t know how to transform<span style="font-family: arial,helvetica,sans-serif;"> a RoutedNomicServer into a NomicServer.</span><br><br>For the future I intend to use formlets: is these some examples of programs using happstack + web-routes + formlets?<br>
<br>Thanks,<br>Corentin<br><br><br><br><br><div class="gmail_quote">On Fri, Jan 7, 2011 at 5:10 PM, Jeremy Shaw <span dir="ltr">&lt;<a href="mailto:jeremy@n-heptane.com">jeremy@n-heptane.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello,<br>
<br>
The [(String, String)] argument is for adding query parameters.<br>
<br>
&gt; encodePathInfo [&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;] [(&quot;key&quot;,&quot;value&quot;)]<br>
<br>
&quot;foo/bar/baz?key=value&quot;<br>
<br>
Instead of showURL you would use showURLParams.<br>
<br>
hope this helps!d<br>
- jeremy<br>
<br>
On Fri, Jan 7, 2011 at 8:12 AM, Corentin Dupont<br>
<div class="im">&lt;<a href="mailto:corentin.dupont@gmail.com">corentin.dupont@gmail.com</a>&gt; wrote:<br>
</div><div><div></div><div class="h5">&gt; Hello Jeremy,<br>
&gt; I&#39;m using Web routes with happstack.<br>
&gt; I&#39;m following this tutorial:<br>
&gt; <a href="http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html" target="_blank">http://tutorialpedia.org/tutorials/Happstack+type+safe+URLs.html</a><br>
&gt;<br>
&gt; But It seems out of synch with the latest version of web-routes: 0.23.2.<br>
&gt; The haddock documentation seems out of date also:<br>
&gt;<br>
&gt; encodePathInfo :: [String] -&gt; [(String, String)] -&gt; String<br>
&gt;<br>
&gt; For example:<br>
&gt;<br>
&gt;  encodePathInfo [\&quot;foo\&quot;, \&quot;bar\&quot;, \&quot;baz\&quot;]<br>
&gt;<br>
&gt; &quot;foo/bar/baz&quot;<br>
&gt;<br>
&gt; And I can&#39;t figure out what this [(String, String)] is for ;)<br>
&gt;<br>
&gt; Thanks,<br>
&gt;<br>
&gt; Corentin<br>
&gt;<br>
</div></div></blockquote></div><br>