mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 11:37:01 -07:00
Initial commit
This commit is contained in:
commit
c04107cf3d
6 changed files with 131 additions and 0 deletions
28
handler.go
Normal file
28
handler.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"html/template"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (app *App) dashboardHandler() http.HandlerFunc {
|
||||
return func(writer http.ResponseWriter, request *http.Request) {
|
||||
tmpl, err := template.New("index.html").ParseFiles("index.html")
|
||||
if err != nil {
|
||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
session, err := json.Marshal(getSession(request.Context()))
|
||||
if err != nil {
|
||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
err = tmpl.ExecuteTemplate(writer, "index.html", string(session))
|
||||
if err != nil {
|
||||
http.Error(writer, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue