How it works...

Once we run the program, the HTTP server will start locally listening on port 8443.

Next, execute a POST request from the command line as:

$ curl -X POST --data "name=Foo&email=aggarwalarpit.89@gmail.com" https://localhost:8443/post --insecure

It will give you the Forbidden - CSRF token invalid message as a response from the server and forbids you to submit an HTML form because the server does not find a valid CSRF token as part of the request:

So, to submit a form, firstly we have to sign up, which generates a valid CSRF token by executing the following command:

$ curl -i -X GET https://localhost:8443/signup --insecure

This ...

Get Go Web Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.