MCPcopy Index your code
hub / github.com/derekbanas/Go-Tutorial / interactHandler

Function interactHandler

webapp/webapp.go:51–72  ·  view source on GitHub ↗
(writer http.ResponseWriter,
	request *http.Request)

Source from the content-addressed store, hash-verified

49}
50
51func interactHandler(writer http.ResponseWriter,
52 request *http.Request) {
53
54 // Get our text from the file
55 todoVals := getStrings("todos.txt")
56
57 // Print to the terminal
58 fmt.Printf("%#v\n", todoVals)
59 // Create a template using the html
60 tmpl, err := template.ParseFiles("view.html")
61 errorCheck(err)
62
63 // Create a todo list with the number
64 todos := ToDoList{
65 ToDoCount: len(todoVals),
66 ToDos: todoVals,
67 }
68
69 // Write the template to the ResponseWriter
70 // Pass the todo struct data
71 err = tmpl.Execute(writer, todos)
72}
73
74// Retreives lines of text from a file
75func getStrings(fileName string) []string {

Callers

nothing calls this directly

Calls 2

getStringsFunction · 0.85
errorCheckFunction · 0.85

Tested by

no test coverage detected