Skip to content

Commit

Permalink
add Use*() option functino to help set custom generator for go-mir
Browse files Browse the repository at this point in the history
  • Loading branch information
alimy committed Jul 27, 2023
1 parent 763aadd commit 0ca44c4
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changelog

All notable changes to paopao-ce are documented in this file.
## 4.0.0+dev ([`dev`](https://github.com/alimy/mir))
## 4.0.0 ([`dev`](https://github.com/alimy/mir))
### Added
- add `gin` engine support for go-mir v4
- add `chi` engine support for go-mir v4
Expand Down
63 changes: 63 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,69 @@ func GeneratorName(name string) Option {
})
}

// UseGin use Gin engine generator
func UseGin() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorGin
})
}

// UseChi use Chi engine generator
func UseChi() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorChi
})
}

// UseMux use Mux engine generator
func UseMux() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorMux
})
}

// UseHertz use Hertz engine generator
func UseHertz() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorHertz
})
}

// UseEcho use Echo engine generator
func UseEcho() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorEcho
})
}

// UseIris use Iris engine generator
func UseIris() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorIris
})
}

// UseFiber use Fiber engine generator
func UseFiber() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorFiber
})
}

// UseMacaron use Macaron engine generator
func UseMacaron() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorMacaron
})
}

// UseHttpRouter use HttpRouter engine generator
func UseHttpRouter() Option {
return optFunc(func(opts *InitOpts) {
opts.GeneratorName = GeneratorHttpRouter
})
}

// ParserName set parser name option
func ParserName(name string) Option {
return optFunc(func(opts *InitOpts) {
Expand Down

0 comments on commit 0ca44c4

Please sign in to comment.