barcodes/web/help.go
2023-09-01 23:01:08 +01:00

33 lines
624 B
Go

package web
import (
"html/template"
"net/http"
"git.fjla.uk/fred.boniface/barcodes/validation"
)
func buildPage(w http.ResponseWriter, r *http.Request) {
i := 0
barcodeOptions := make([]string, len(validation.FormatRules))
for k := range validation.FormatRules {
barcodeOptions[i] = k
i++
}
type dataType struct {
BarcodeOptions []string
}
data := dataType{
BarcodeOptions: barcodeOptions,
}
tmpl := template.Must(template.New("help.html").ParseFiles("templates/help.html"))
err := tmpl.Execute(w, data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}