Begin implementation of formatted barcodes
This commit is contained in:
32
web/help.route.go
Normal file
32
web/help.route.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user