
Okay this is what I have so far, concerning what I need to do on the Haskell end of things to get it working with lighttpd. As an example, I will use blog.lhs from the yesod tutorial All that's left now is the main function. Yesod is built on top of WAI, so you can use any WAI handler you wish. For the tutorials, we'll use the basicHandler that comes built-in with Yesod: it serves content via CGI if the appropriate environment variables are available, otherwise with simpleserver.
main :: IO () main = do entries <- loadEntries basicHandler 3000 $ Blog entries
This brings into sharp relief my ignorance on how to use hackage. I
tried to investigate hackage looking for some WAI handler that would
get me what I want. Namely, turning this example into a fastCGI
application that lighttpd could use.
So this generates two questions. How would one use hackage to find a
WAI handler to use for fastCGI?
What would be an example of a WAI handler I could use with yesod?
Thanks for making it possible for guys like me to do this.
On Thu, Jul 15, 2010 at 9:33 AM, Michael Snoyman
On Thu, Jul 15, 2010 at 6:57 PM, Michael Litchard
wrote: I'm playing with yesod http://docs.yesodweb.com/yesod/, and I have a few questions:
Here's an excerpt from yesod/tutorial/i18n.lhs
**NOTE: This tutorial requires the development version of Yesod (version 0.4.0). The [tutorial main page]($root/yesod/tutorial/) has instructions on setting up your environment.**
Where is $root? I thought it was where yesod-examples-0.4.0 was installed. But if this is the case, I'm not finding these instructions. This makes me think I am confused about the directory $root represents.
Sorry about the $root stuff, it's an artifact from the web site. I use the same code base for the yesod-examples package and the tutorials on the site to make sure everything compiles properly. In any event, the line in question is out-of-date and needs to be removed: 0.4.0 has been officially released, so you just need a cabal install yesod to get started.
I was playing around with the code and made some changes. Here is the line in question, with the complete code below for context.
instance Yesod I18N where approot _ = ""
This does what I expect it to do, it runs the program when I open up http://my.blog.server/
however, I wanted to see what would happen if I played around with it a little bit. I want the same program to run when I point my browser to http://my.blog.server/blog
so I made this change
approot _ = "/blog"
but now when I point my browser to http://my.blog.server/blog it gets re-written to http:/my.blog.server/blog/blog and then this error message Not Found /blog/blog
Not sure what is going on here, could someone enlighten me?
The approot function is used for *rendering* routes. This has no affect on where Yesod *listens* to requests. For example, you could put approot _ = "http://haskell.org", but you wouldn't be able to respond to requests for that domain. Nonetheless, URLs generated by Yesod would then point to haskell.org. Basically, the only time to get fancy with approot is when you're doing URL rewriting for (Fast)CGI hosted applications. When you use a standalone server, you'll always* be serving from the root of the domain, and so the value of approot should just be that domain name. * Of course, there's always exceptions. You might look at the documentation[1] where it explains when it's permissible to use an empty string for the value of approot. Michael [1] http://docs.yesodweb.com/haddock/yesod/Yesod-Yesod.html#v%3Aapproot