Begin implementation of formatted barcodes

This commit is contained in:
Fred Boniface
2023-09-02 22:05:46 +01:00
parent d3bd2673e8
commit 4dad1406eb
9 changed files with 87 additions and 4 deletions

32
web/help.route.go Normal file
View File

@@ -0,0 +1,32 @@
package web
import (
"html/template"
"net/http"
"git.fjla.uk/fred.boniface/barcodes/validation"
)
func helpTemplate(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
}
}