notfall/main.go

42 lines
796 B
Go

package main
import (
_ "embed"
"encoding/json"
"fmt"
"html/template"
"net/http"
)
var lastData interface{}
//go:embed notfall.tmpl
var templateContent []byte
func main() {
http.HandleFunc("/owntrack", func(writer http.ResponseWriter, request *http.Request) {
var p map[string]interface{}
err := json.NewDecoder(request.Body).Decode(&p)
if err != nil {
writer.WriteHeader(http.StatusInternalServerError)
return
}
if p["_type"] == "location"{
lastData = p
}
fmt.Println(p)
writer.Write([]byte("[]"))
})
http.HandleFunc("/", func(writer http.ResponseWriter, request *http.Request) {
templ := template.Must(template.New("page").Parse(string(templateContent)))
templ.Execute(writer, map[string]interface{}{
})
})
http.ListenAndServe(":8080", nil)
}