Hello and welcome to the Golang programming language course in the previous session, we could define
a say, the student function for rest later and now it's time to implement another function that is
supposed to update exists.
A student from personal database so defined the function names like Update a student.
This function accept two parameters first and object from a response writer.
And second, the pointer appears to be request.
So we write for update.
A student set two parameters first response from IS to response writer and second request as pointer
of Institute Author request.
Now we to implement the body of the function.
This function is supposed to update existing student in database, so we should convert the data received
from the end point into a student object and save it in the database.
To do this, we do the following first create an object of a student model by the student.
Model law student, therefore, we received a data sent from the killer through the body and the request
by the new theycould function from Jason Pichet and associate into a student object, this function
returns a new decoder that reads from reader, so first define an error variable as return type error
column.
E calls Jason Dart's new decoder and Seth body of recklessness argument with body and calling decode
function, decode function and store to receive data into a student model.
Anderson student.
Now, check the NRA status, so be right, if error not equals nil of the
error.
And sits an error of state was in response Heather and displayed for a client by their printer function.
So the right response dots, right?
Heather select an error status, for example, STP dot status, internal server status, internal server
error and displayed for client by the colleague.
If M t dot f trent f function first response, second parameter set and misses, for example, could
not update.
Student.
By Edward Pierce, and we and sit anywhere valuable.
And set a return value return.
We can now connect to the database, then call the query to update a student, so we write the tools
and calling update function updates and sit a student as our human for this function.
Student OK before the call and say the perfect.
Now we were able to implement the update function.
That Update and N'existe, a student from the database based data receiving from Client The Rest API.
OK.
In this session, we will able to implement the necessary functions to connect the rest API to the database
in order not to prolong the time of decision.
We will finish it, then we will continue the content in the next session.
Goodbye.