Skip to Main Content
Developing Web Applications with Haskell and Yesod
book

Developing Web Applications with Haskell and Yesod

by Michael Snoyman
April 2012
Intermediate to advanced content levelIntermediate to advanced
294 pages
6h 27m
English
O'Reilly Media, Inc.
Content preview from Developing Web Applications with Haskell and Yesod

Chapter 12. RESTful Content

One of the stories from the early days of the Web is how search engines wiped out entire websites. When dynamic web sites were still a new concept, developers didn’t appreciate the difference between a GET and POST request. As a result, they created pages—accessed with the GET method—that would delete pages. When search engines started crawling these sites, they could wipe out all the content.

If these web developers had followed the HTTP spec properly, this would not have happened. A GET request is supposed to cause no side effects (you know, like wiping out a site). Recently, there has been a move in web development to properly embrace Representational State Transfer, also known as REST. This chapter describes the RESTful features in Yesod and how you can use them to create more robust web applications.

Request Methods

In many web frameworks, you write one handler function per resource. In Yesod, the default is to have a separate handler function for each request method. The two most common request methods you will deal with in creating websites are GET and POST. These are the most well-supported methods in HTML, since they are the only ones supported by web forms. However, when creating RESTful APIs, the other methods are very useful.

Technically speaking, you can create whichever request methods you like, but it is strongly recommended to stick to the ones spelled out in the HTTP spec. The most common of these are:

GET

Read-only requests. Assuming no other ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Developing Web Apps with Haskell and Yesod, 2nd Edition

Developing Web Apps with Haskell and Yesod, 2nd Edition

Michael Michael Snoyman Snoyman

Publisher Resources

ISBN: 9781449336868Supplemental ContentErrata Page