[fix] Renamed amqp var and make it public

This commit is contained in:
Piotr Biernat 2020-09-30 22:12:50 +02:00
parent 27222a479e
commit f0bb9cf00d
3 changed files with 5 additions and 5 deletions

View File

@ -43,7 +43,7 @@ type ArticleGenerateHeavyPDFMessage struct {
func (h *ArticlesHandler) testRabbit(c echo.Context) error { func (h *ArticlesHandler) testRabbit(c echo.Context) error {
log.Println("test rabbit publish method calling...") log.Println("test rabbit publish method calling...")
q := h.amqp.DeclareQueue("article_queue_test") q := h.Queue.DeclareQueue("article_queue_test")
m := ArticleGenerateHeavyPDFMessage{ m := ArticleGenerateHeavyPDFMessage{
Title: "Test title", Title: "Test title",
Content: "Lorem ipsum dolor sit amet", Content: "Lorem ipsum dolor sit amet",
@ -51,7 +51,7 @@ func (h *ArticlesHandler) testRabbit(c echo.Context) error {
} }
body, _ := h.JSONEncode(m) body, _ := h.JSONEncode(m)
h.amqp.Publish(q.Name, body, "application/json") h.Queue.Publish(q.Name, body, "application/json")
response := "Please wait until generating pdf or some other long task (in rabbitMQ queue) done" response := "Please wait until generating pdf or some other long task (in rabbitMQ queue) done"
return c.JSON(http.StatusOK, response) return c.JSON(http.StatusOK, response)

View File

@ -29,16 +29,16 @@ func DeserializeFromRequest(request *http.Request, output interface{}) {
// BaseHandler type // BaseHandler type
type BaseHandler struct { type BaseHandler struct {
Queue *queue.AMQP
db *database.MongoDb db *database.MongoDb
amqp *queue.AMQP
validator *validator.Validate validator *validator.Validate
} }
// NewHandler Create BaseHandler instance // NewHandler Create BaseHandler instance
func NewHandler() *BaseHandler { func NewHandler() *BaseHandler {
return &BaseHandler{ return &BaseHandler{
Queue: queue.New(),
db: database.New(), db: database.New(),
amqp: queue.New(),
validator: validator.New(), validator: validator.New(),
} }
} }

View File

@ -16,7 +16,7 @@ import (
var port = ":8000" var port = ":8000"
func main() { func main() {
// Echo fw setup // framework setup
e := echo.New() e := echo.New()
e.Use(middleware.Logger()) e.Use(middleware.Logger())
e.Use(middleware.Recover()) e.Use(middleware.Recover())