Notes Creation API
Explore how to create a Notes Creation API using Golang and the Beego framework. Learn to set up routes, handle form submissions, and use ORM to save new notes in the database. This lesson teaches the practical implementation of creating and storing notes in a CRUD application.
The new note form page
We will start with creating an HTML form to enter the details of a new note.
Route
First, let’s create the route of the /notes/new page. In the routers/router.go file, create a new entry:
We define the route for the new note form in line 12. The route is /notes/new. The action for the route is get:NotesNewForm. This means that the NotesNewForm() method in the NotesController controller will be executed when the route is requested.
The notes form handler
Now, we will implement the handler function for the above route in the file controllers/notes.go.
In this ...