diff --git a/handlers/index.go b/handlers/index.go index 8ec8ab0..594afd9 100644 --- a/handlers/index.go +++ b/handlers/index.go @@ -4,10 +4,11 @@ import ( "net/http" "text/template" + "git.espin.casa/albert/cml04-falcon-ui/storage" "github.com/julienschmidt/httprouter" ) -func IndexHandler() httprouter.Handle { +func IndexHandler(storage storage.Storager) httprouter.Handle { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { t, _ := template.ParseFiles("templates/base.html", "templates/index.html") err := t.Execute(w, nil) diff --git a/handlers/labels.go b/handlers/labels.go new file mode 100644 index 0000000..3a9ce89 --- /dev/null +++ b/handlers/labels.go @@ -0,0 +1,19 @@ +package handlers + +import ( + "net/http" + "text/template" + + "github.com/julienschmidt/httprouter" +) + +func LabelsHandler() httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + t, _ := template.ParseFiles("templates/base.html", "templates/labels.html") + err := t.Execute(w, nil) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + } +} diff --git a/handlers/standards.go b/handlers/standards.go new file mode 100644 index 0000000..ce30093 --- /dev/null +++ b/handlers/standards.go @@ -0,0 +1,20 @@ +package handlers + +import ( + "net/http" + "text/template" + + "git.espin.casa/albert/cml04-falcon-ui/storage" + "github.com/julienschmidt/httprouter" +) + +func StandardsHandler(storage storage.Storager) httprouter.Handle { + return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { + t, _ := template.ParseFiles("templates/base.html", "templates/standards.html") + err := t.Execute(w, nil) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + } +} diff --git a/routes/routes.go b/routes/routes.go index e18f058..acbe72d 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -7,8 +7,13 @@ import ( ) func CreateRoutes(r *httprouter.Router, storage storage.Storager) { - r.GET("/", handlers.IndexHandler()) + r.GET("/", handlers.IndexHandler(storage)) r.GET("/hbcp", handlers.HBCPHandler(storage)) + r.GET("/po", handlers.PoHandler(storage)) + r.GET("/co", handlers.CoHandler(storage)) + r.GET("/bcp", handlers.BCPHandler(storage)) + r.GET("/lcp", handlers.LCPHandler(storage)) r.GET("/barcodes", handlers.BarcodesHandler(storage)) - + r.GET("/labels", handlers.LabelsHandler()) + r.GET("/standards", handlers.StandardsHandler(storage)) } diff --git a/server/server.go b/server/server.go deleted file mode 100644 index 53af738..0000000 --- a/server/server.go +++ /dev/null @@ -1,34 +0,0 @@ -package server - -import ( - "net/http" - "time" -) - -type Server struct { - Url string -} - -func (s *Server) Start() error { - - // Crear un servidor HTTP - server := http.Server{ - Addr: s.Url, - ReadTimeout: 5 * time.Second, // time limit for reading - WriteTimeout: 5 * time.Second, // time limit for writting - IdleTimeout: 5 * time.Second, - } - // start api - go func() { - if err := server.ListenAndServe(); err != nil { - panic(err) - } - }() - return nil -} - -func New(url string) *Server { - return &Server{ - Url: url, - } -} diff --git a/templates/barcodes.html b/templates/barcodes.html index 2abc397..d344170 100644 --- a/templates/barcodes.html +++ b/templates/barcodes.html @@ -12,7 +12,7 @@ diff --git a/templates/co.html b/templates/co.html new file mode 100644 index 0000000..91a84f4 --- /dev/null +++ b/templates/co.html @@ -0,0 +1,49 @@ +{{define "title"}}Falcon UI{{end}} + +{{define "body"}} + +
+
+
+ +
+ +
+ +
+
+
+{{ end }} \ No newline at end of file diff --git a/templates/hbcp.html b/templates/hbcp.html index 20bd42b..ecf15f3 100644 --- a/templates/hbcp.html +++ b/templates/hbcp.html @@ -12,7 +12,7 @@ diff --git a/templates/index.html b/templates/index.html index b1f997c..d3279be 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,7 +2,6 @@ {{define "body"}} -
@@ -69,6 +68,7 @@ diff --git a/templates/labels.html b/templates/labels.html new file mode 100644 index 0000000..d969caa --- /dev/null +++ b/templates/labels.html @@ -0,0 +1,54 @@ +{{define "title"}}Falcon UI{{end}} + +{{define "body"}} + +
+
+
+ +
+ +
+ + +
+
+
+{{ end }} \ No newline at end of file diff --git a/templates/standards.html b/templates/standards.html new file mode 100644 index 0000000..91a84f4 --- /dev/null +++ b/templates/standards.html @@ -0,0 +1,49 @@ +{{define "title"}}Falcon UI{{end}} + +{{define "body"}} + +
+
+
+ +
+ +
+ +
+
+
+{{ end }} \ No newline at end of file