wip
This commit is contained in:
parent
1cb83dbde6
commit
49fb704bb1
@ -8,8 +8,8 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.espin.casa/albert/cml04-falcon-system/handset/publisher"
|
||||
"git.espin.casa/albert/cml04-falcon-system/handset/routes"
|
||||
"git.espin.casa/albert/cml04-falcon-system/internal/publisher"
|
||||
"git.espin.casa/albert/logger"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
"github.com/nats-io/nats.go"
|
||||
|
@ -3,14 +3,14 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.espin.casa/albert/cml04-falcon-system/handset/publisher"
|
||||
"git.espin.casa/albert/cml04-falcon-system/internal/publisher"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
func BarCodeHandler(publisher publisher.Publisher) httprouter.Handle {
|
||||
return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
barcode := ps.ByName("barcode")
|
||||
if err := publisher.Barcode(r.Context(), barcode); err != nil {
|
||||
if err := publisher.NewBarcode(r.Context(), barcode); err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package routes
|
||||
|
||||
import (
|
||||
"git.espin.casa/albert/cml04-falcon-system/handset/handlers"
|
||||
"git.espin.casa/albert/cml04-falcon-system/handset/publisher"
|
||||
"git.espin.casa/albert/cml04-falcon-system/internal/publisher"
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
||||
|
@ -10,14 +10,14 @@ import (
|
||||
)
|
||||
|
||||
type Publisher interface {
|
||||
Barcode(ctx context.Context, barcode string) error
|
||||
NewBarcode(ctx context.Context, barcode string) error
|
||||
}
|
||||
|
||||
type publisher struct {
|
||||
nc *nats.Conn
|
||||
}
|
||||
|
||||
func (e *publisher) Barcode(ctx context.Context, barcode string) error {
|
||||
func (e *publisher) NewBarcode(ctx context.Context, barcode string) error {
|
||||
// create event message
|
||||
evt := cml04eventer.NewEvent("falcon-handset", "barcode.new", nil, []byte(barcode))
|
||||
// create buffer message data
|
Loading…
Reference in New Issue
Block a user