Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

TDC2018SP | Trilha Go - Case Easylocus

814 views

Published on

TDC2018SP | Trilha Go - Case Easylocus

Published in: Education
  • Be the first to comment

TDC2018SP | Trilha Go - Case Easylocus

  1. 1. AS AVENTURAS QUE RESULTARAM NA NOSSA API DE ENDERE�OS EM GO Case EasyLocus
  2. 2. @PAULOELR EASY @HENRIQUEHOLANDA EASY
  3. 3. OBJETIVOS
  4. 4. O PROBLEMA
  5. 5. BEEGO
  6. 6. GO PURO
  7. 7. ESCALABILIDADE
  8. 8. GERENCIAMENTO DE DEPEND�NCIAS
  9. 9. MIDDLEWARES
  10. 10. package middlewares import ( "easytaxi/easylocus/entities" "net/http" ) type NotFoundMiddleware struct { Next http.Handler } func (controller NotFoundMiddleware) ServeHTTP(writer http.ResponseWriter, request *http.Request) { path := request.URL.Path routes := entities.Routes for _, route := range routes { if route.Path == path { controller.Next.ServeHTTP(writer, request) return } } http.NotFound(writer, request) } MIDDLEWARES
  11. 11. package middlewares import ( NewRelicService "easytaxi/easylocus/services/newrelic" "github.com/newrelic/go-agent" "net/http" ) type NewRelicMiddleware struct { Next http.Handler } func (controller NewRelicMiddleware) ServeHTTP(writer http.ResponseWriter, request *http.Request) { if NewRelicService.Agent != nil { _, newRelicHandler := newrelic.WrapHandle( NewRelicService.Agent, request.URL.Path, http.Handler(controller.Next), ) newRelicHandler.ServeHTTP(writer, request) return } controller.Next.ServeHTTP(writer, request) } MIDDLEWARES
  12. 12. func main() { http.Handle( entities.RootEndpoint, middlewares.NotFoundMiddleware{ middlewares.NewRelicMiddleware{ controllers.IndexController{}, }, }, ) http.Handle( entities.PlaceEndpoint, middlewares.NotFoundMiddleware{ middlewares.NewRelicMiddleware{ middlewares.AuthenticationMiddleware{ controllers.PlaceController{}, }, }, }, ) log.Fatal(http.ListenAndServe(":"+conf.GetConfigs().Port, nil)) } ROUTES
  13. 13. METRICAS
  14. 14. METRICAS
  15. 15. METRICAS
  16. 16. AUTENTICA��O
  17. 17. LOGS
  18. 18. CONCLUS�O
  19. 19. OBRIGADO

×