March 2019
Intermediate to advanced
336 pages
9h 9m
English
The Insert function invokes the GetCustomers method to get an array of customers and renders the Home template with the writer and customers arrays as parameters by invoking the ExecuteTemplate method. This is shown in the following code:
// Insert - execute templatefunc Insert(writer http.ResponseWriter, request *http.Request) { var customer Customer customer.CustomerName = request.FormValue("customername") customer.SSN = request.FormValue("ssn") InsertCustomer(customer) var customers []Customer customers = GetCustomers() template_html.ExecuteTemplate(writer,"Home",customers)}
Read now
Unlock full access