Rendering dynamic content
Now that we understand how to serve static content using the net/http
package, let’s take a look at adding some dynamic content using Gorilla Mux found here: https://github.com/PacktPublishing/Full-Stack-Web-Development-with-Go/tree/main/Chapter04/dynamic. Execute the server using the following command:
go run main.go
Launch your browser and enter http://localhost:3333
as the address; you will see a login screen similar to the static content. Perform the following steps on the login screen:
- Enter any combination of username and password on the login screen.
- Click the Login button.
You will get a Login unsuccessful message, as shown in Figure 4.4.
Figure 4.4 – Message screen after login
We have introduced dynamic content for our login operation, which means the application will serve pages based on certain conditions, in this case, the successful validation of the username/password combination...