29 lines
610 B
Go
29 lines
610 B
Go
package web
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
)
|
|
|
|
func StartServer() {
|
|
// What I want to do here is server from /static
|
|
// if the resource exists, else try to render from /templates
|
|
// if the template exists. Else return 404.
|
|
|
|
http.HandleFunc("/", rootHandler)
|
|
|
|
http.HandleFunc("/help", helpTemplate) // Rendered with props passed in
|
|
|
|
http.HandleFunc("/generate", generateBarcode)
|
|
|
|
http.HandleFunc("/generate/formatted", generateFormattedBarcode)
|
|
|
|
port := ":8500"
|
|
fmt.Printf("Server listening on port %s\n", port)
|
|
|
|
err := http.ListenAndServe(port, nil)
|
|
if err != nil {
|
|
fmt.Println("Error: ", err)
|
|
}
|
|
}
|