March 2019
Intermediate to advanced
336 pages
9h 9m
English
The Delete method renders the Home template after deleting the customer that's found by the GetCustomerById method. The View method renders the View template after finding the customer by invoking the GetCustomerById method:
// Delete - execute Templatefunc Delete(writer http.ResponseWriter, request *http.Request) { var customerId int var customerIdStr string customerIdStr = request.FormValue("id") fmt.Sscanf(customerIdStr, "%d", &customerId) var customer Customer customer = GetCustomerById(customerId) DeleteCustomer(customer) var customers []Customer customers = GetCustomers() template_html.ExecuteTemplate(writer,"Home",customers)}// View - execute Templatefunc View(writer http.ResponseWriter, request *http.Request) { ...Read now
Unlock full access