Notes Edit Page
Learn to implement an API to edit/update a new note/record in a Beego application.
We'll cover the following...
Editing a note
Now, we are going to implement routes/API to edit the details of a note.
First, we will create a page that will have a form filled with the details of the note. These details can be edited, and when we submit the form, it updates the note.
Let’s start by defining a new route in the routers/route.go file.
We added two routes to the project: /notes/edit/:id([0-9]+) and /notes/:id. The :id part of the route is a placeholder for the note Id. The [0-9]+ part of the route specifies that the note Id must be a number.
Here are the details of the new routes:
Line 15: This route has the
getmethod and theNotesEditPageaction. This route means that when the/notes/edit/:id([0-9]+)path is requested, theNotesEditPage()action in theNotesControllercontroller will be executed. TheNotesEditPage()action will get the note with the specifiedidfrom the database and render the edit note page.Line 16: The
/notes/:idroute has thepostmethod and the ...