Skip to content

Commit

Permalink
feat: refactor RouteAPI function in container.go for dynamic options
Browse files Browse the repository at this point in the history
- Import the "slices" package in `container.go`
- Update the `RouteAPI` function in `container.go` to accept a variable number of options
- The `WithLogger` option is now included dynamically in the array of options within `RouteAPI`

Signed-off-by: Jqs7 <[email protected]>
  • Loading branch information
jqs7 committed Apr 27, 2024
1 parent ca49a9f commit fe8ea51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions container.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http/httptest"
"os"
"reflect"
"slices"

"github.com/emicklei/go-restful/v3"
"github.com/go-openapi/spec"
Expand Down Expand Up @@ -224,6 +225,6 @@ func (c *Container) NewWS() WS {
}
}

func (c *Container) RouteAPI(f any) opt.RouteFunc {
return opt.RouteAPI(f, opt.WithLogger(c.logger))
func (c *Container) RouteAPI(f any, opts ...opt.RouteAPIOpts) opt.RouteFunc {
return opt.RouteAPI(f, slices.Concat([]opt.RouteAPIOpts{opt.WithLogger(c.logger)}, opts)...)

Check failure on line 229 in container.go

View workflow job for this annotation

GitHub Actions / test (1.21.x)

undefined: slices.Concat

Check failure on line 229 in container.go

View workflow job for this annotation

GitHub Actions / test (1.21.x)

undefined: slices.Concat
}

0 comments on commit fe8ea51

Please sign in to comment.