go-mojito/mojito

[Bug]: Middleware must be applied first or won't be called

Closed this issue · 0 comments

Description

If middleware is not registered first it won't be called.

How to Reproduce

  1. Create a new mojito project
  2. Register middleware after registering routes
  3. Middleware will not be called

Expected Behavior

Middleware can be applied at any point in time before ListenAndServe is called

Version

v0.0.14

Code Snippet

package main

import "github.com/go-mojito/mojito"

func main() {
  mojito.GET("/", func(ctx mojito.Context) {
    ctx.String("Hello World")
  })
  mojito.WithMiddleware(middleware.Logging)
  mojito.ListenAndServe(":8123")
}

Checklist:

  • I agree to follow Mojito's Code of Conduct.
  • I have checked for existing issues that describe my problem prior to opening this one.
  • I understand that improperly formatted bug reports may be closed without explanation.