Skip to content

Commit

Permalink
don't return nil ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
jyecusch committed Sep 25, 2024
1 parent f6e9756 commit 661ac55
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nitric/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ func (c *chainedMiddleware[T]) invoke(ctx *T) (*T, error) {
c.nextFunc = dummyHandler[T]
}

outCtx, err := c.fun(ctx, c.nextFunc)

// The returned context should never be nil, since it's used to create the response.
// If it is, return the current context and the error
if outCtx == nil {
return ctx, err
}

return c.fun(ctx, c.nextFunc)
}

Expand Down

0 comments on commit 661ac55

Please sign in to comment.