[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 {
log.Println("test rabbit publish method calling...")
q := h.amqp.DeclareQueue("article_queue_test")
q := h.Queue.DeclareQueue("article_queue_test")
m := ArticleGenerateHeavyPDFMessage{
Title: "Test title",
Content: "Lorem ipsum dolor sit amet",
@ -51,7 +51,7 @@ func (h *ArticlesHandler) testRabbit(c echo.Context) error {
}
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"
return c.JSON(http.StatusOK, response)

View File

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

View File

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