MCPcopy Create free account
hub / github.com/dinofizz/diskplayer / indexHandler

Function indexHandler

server.go:124–134  ·  view source on GitHub ↗

indexHandler handles requests to the server for the root location "/". A listing of the attached devices is obtained and applied to the index.html template response. An error page is returned if an error occurred.

(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

122// A listing of the attached devices is obtained and applied to the index.html template response.
123// An error page is returned if an error occurred.
124func indexHandler(w http.ResponseWriter, r *http.Request) {
125 cmd := exec.Command("lsblk", "--nodeps")
126 stdout, err := cmd.Output()
127 if err != nil {
128 errorPage(w, err);
129 }
130
131 p := &IndexPage{Lsblk: stdout}
132 t, _ := template.ParseFiles("./templates/index.html")
133 t.Execute(w, p)
134}
135
136// errorPage returns an HTML error page, inserting error details into the error.html template.
137func errorPage(w http.ResponseWriter, err error) {

Callers

nothing calls this directly

Calls 1

errorPageFunction · 0.85

Tested by

no test coverage detected