Use chi style middle ware

This commit is contained in:
James Jeffrey
2017-07-19 13:44:26 -07:00
committed by Travis Reeder
parent 570e9265f1
commit cf2c3cf404
21 changed files with 192 additions and 240 deletions

View File

@@ -28,21 +28,21 @@ type runnerResponse struct {
}
func (s *Server) handleSpecial(c *gin.Context) {
ctx := c.MustGet("ctx").(context.Context)
ctx := c.Request.Context()
ctx = context.WithValue(ctx, api.AppName, "")
c.Set(api.AppName, "")
ctx = context.WithValue(ctx, api.Path, c.Request.URL.Path)
c.Set(api.Path, c.Request.URL.Path)
ctx, err := s.UseSpecialHandlers(ctx, c.Request, c.Writer)
r, err := s.UseSpecialHandlers(c.Writer, c.Request)
if err != nil {
handleErrorResponse(c, err)
return
}
c.Set("ctx", ctx)
c.Set(api.AppName, ctx.Value(api.AppName).(string))
c.Request = r
c.Set(api.AppName, r.Context().Value(api.AppName).(string))
if c.MustGet(api.AppName).(string) == "" {
handleErrorResponse(c, models.ErrRunnerRouteNotFound)
return
@@ -66,7 +66,7 @@ func (s *Server) handleRequest(c *gin.Context, enqueue models.Enqueue) {
return
}
ctx := c.MustGet("ctx").(context.Context)
ctx := c.Request.Context()
reqID := id.New().String()
ctx, log := common.LoggerWithFields(ctx, logrus.Fields{"call_id": reqID})