February 2018
Intermediate to advanced
340 pages
9h 43m
English
The net/http package contains a simple way of executing the redirect. The RedirectHandler could be utilized. The function consumes the URL where the request will be redirected and the status code which will be sent to client. The function itself sends results to the Handler, which could be used in the Handle method of ServeMux (the example uses the default one directly from the package).
The second approach is the use of the Redirect function, which does the redirect for you. The function consumes ResponseWriter, the request pointer and the same as RequestHandler, the URL and status code, which will be sent to the client.
Read now
Unlock full access