Serving and Embedding HTML Content
As we build on our foundations, it is important that we look at another aspect of processing HTTP user requests, routing. Routing is useful as it allows us to structure our application to handle different functionality for certain HTTP methods, such as a GET
that can retrieve and a POST
on the same route that can replace the data. This concept is the fundamental principle of designing a REST-based application. We’ll end the chapter by looking at how we can use the new embed
directive introduced in Go version 1.16 to bundle our web app as a single self-contained executable. This chapter will provide us with the tools to handle user data and create the interface for the user.
By the end of this chapter, you will have learned how static and dynamic content is served by the application. You will also have learned how to embed all the different assets (icons, .html
, .css
, etc.) that will be served by the web application in the application using...