Skip to content
Ian Stewart-Binks edited this page Jan 16, 2015 · 20 revisions

Under Construction

Request

A Request represents an HTTP request. This generally means that a user is either asking for data from the server, or trying to give data to the server.

These two methods are generally defined as:

  •  GET : Get a file/data from the server.  
    
  •  POST : Give data to the server.
    

In the server, we can ask for the request with the method askRq. Here is a simple example:

reqExample :: ServerPartT IO Response
reqExample =
   do req <- askRq
      ok $ toResponse $ show req

This example can be run in Happstack with the following main method:

code :: String
code = "example"

main :: IO ()
main = do
    simpleHTTP nullConf $
      msum [ dir code $ reqExample
           ]

Now, let's run the example. When the server is running, we can now visit the page http://localhost:8000/example/.

What we now see is the request that you just made in its entirety!

Look here to see which methods we can use to dissect a request.

To takeaway: The 'current' Request can always be accessed.