1234567891011121314151617181920212223242526272829303132333435 |
- package rest
- import (
- "git.nspix.com/golang/micro/gateway/http"
- "gorm.io/gorm"
- )
- type Options struct {
- EnableNamespace bool
- DB *gorm.DB
- Prefix string
- Formatter *Formatter
- Middleware []http.Middleware
- }
- type Option func(o *Options)
- func WithPrefix(prefix string) Option {
- return func(o *Options) {
- o.Prefix = prefix
- }
- }
- func WithDB(db *gorm.DB) Option {
- return func(o *Options) {
- o.DB = db
- }
- }
- func NewOptions() *Options {
- return &Options{
- Formatter: DefaultFormatter,
- Middleware: make([]http.Middleware, 0),
- }
- }
|