Skip to content

Commit

Permalink
pass option by value;
Browse files Browse the repository at this point in the history
log by path if option no value;
  • Loading branch information
zerolethanh committed Nov 16, 2022
1 parent 6c31d2b commit e83b22f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,30 @@ type Options struct {
RawPrint bool
}

var DefaultOptions = Options{
var defaultOptions = Options{
PrintByPath: true,
RawPrint: false,
}

// PrintAppStacks will print all routes
func PrintAppStacks(app *fiber.App, options ...*Options) {
func PrintAppStacks(app *fiber.App, options ...Options) {

var opt Options
if len(options) > 0 {
opt = *options[0]
opt = options[0]
} else {
opt = DefaultOptions
opt = defaultOptions
}

stacks := lo.Flatten[*fiber.Route](app.Stack())

color.Blue("-- App Route Stacks (%d) --", len(stacks))
if opt.PrintByPath {
printByPathStacks(stacks)
}
if opt.RawPrint {
} else if opt.RawPrint {
printByJson(stacks)
} else {
printByPathStacks(stacks)
}

}
Expand Down

0 comments on commit e83b22f

Please sign in to comment.