O'Reilly logo

Haskell Cookbook by Yogesh Sajanikar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How it works...

In this recipe, the same route serves both GET and POST methods. We have used the same route twice, once with a GET handler (getSurvey) and another with the handler for the POST request (postSurvey). 

In the GET handler, we use the redirect function to redirect to another location. The redirect function generates an  HTTP 302 redirection request to another location. 

In the POST handler, we use getParams to get the form parameters. The getParams function extracts the parameters from the HTTP request and makes it available as a Map of parameter names against their values. The POST handler extracts the necessary parameters, and then prints the results.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required