package rest import ( "git.nobla.cn/golang/rest/types" "gorm.io/gorm" ) type options struct { urlPrefix string moduleName string disableDomain bool db *gorm.DB router types.HttpRouter writer types.HttpWriter formatter *Formatter } type Option func(o *options) // WithDB 设置DB func WithDB(db *gorm.DB) Option { return func(o *options) { o.db = db } } // WithUriPrefix 模块前缀 func WithUriPrefix(s string) Option { return func(o *options) { o.urlPrefix = s } } // WithModuleName 模块名称 func WithModuleName(s string) Option { return func(o *options) { o.moduleName = s } } // WithoutDomain 禁用域 func WithoutDomain() Option { return func(o *options) { o.disableDomain = true } } // WithHttpRouter 设置HttpRouter func WithHttpRouter(s types.HttpRouter) Option { return func(o *options) { o.router = s } } // WithHttpWriter 配置HttpWriter func WithHttpWriter(s types.HttpWriter) Option { return func(o *options) { o.writer = s } } // WithFormatter 配置Formatter func WithFormatter(s *Formatter) Option { return func(o *options) { o.formatter = s } }