2

I have the following case.

how can i address from handlev1 to handle2, using middleware? that depends on IsActiveBypass

Or what do you suggest?

func Handlev1(sw echoswagger.ApiRoot, itemUseCase usecase.ItemFileUseCase) {
    g := sw.Group("V2", "/v2/items")
    h := &itemHandler{itemUseCase: itemUseCase}
    g.SetDescription("item information")

    sw.Echo().Use(Bypass(sw))

    g.POST("/page1", func(c echo.Context) (err error) {
        ...
    })

    
}

func Handlev2(sw echoswagger.ApiRoot, version string) {
    path := version
    g := sw.Group("GTP", version+"/items")
    g.SetDescription("item information")

    g.POST("/page2", func(c echo.Context) (err error) {
        ...
    })

}

func IsActiveBypass() (clatlasitemapiapi bool) {
    clatlasitemapiapi = true
    return clatlasitemapiapi
}


func Bypass(sw echoswagger.ApiRoot) echo.MiddlewareFunc {
    return func(next echo.HandlerFunc) echo.HandlerFunc {
        if IsActiveBypass() {
            return next(Handlev2(sw, "v2"))
        }
        return nil
    }
}

If IsActiveBypass is true I call handlev2

blackgreen
  • 34,072
  • 23
  • 111
  • 129
Goku
  • 21
  • 1
  • Can you please describe your actual problem a little bit better and define what you mean by `address from` and `middleware`. What do you want to archive. – guenhter Jul 18 '22 at 12:49
  • 1
    You should mention you mean middleware for the Echo framework specifically – donatJ Jul 18 '22 at 15:44

0 Answers0