Barebones HTTP server setup
This commit is contained in:
19
handlers/root.go
Normal file
19
handlers/root.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func HandleRoot() http.Handler {
|
||||
return http.HandlerFunc(
|
||||
func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.URL.Path != "/" {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
templ := template.Must(template.ParseFiles("templates/index.html"))
|
||||
templ.Execute(w, nil)
|
||||
},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user