feat: initial commit
This commit is contained in:
41
internal/http/options.go
Normal file
41
internal/http/options.go
Normal file
@ -0,0 +1,41 @@
|
||||
package http
|
||||
|
||||
import "github.com/gorilla/sessions"
|
||||
|
||||
type Options struct {
|
||||
Address string
|
||||
BaseURL string
|
||||
SessionStore sessions.Store
|
||||
}
|
||||
|
||||
type OptionFunc func(opts *Options)
|
||||
|
||||
func NewOptions(funcs ...OptionFunc) *Options {
|
||||
opts := &Options{
|
||||
Address: ":3000",
|
||||
BaseURL: "",
|
||||
SessionStore: sessions.NewCookieStore(),
|
||||
}
|
||||
for _, fn := range funcs {
|
||||
fn(opts)
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func WithBaseURL(baseURL string) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.BaseURL = baseURL
|
||||
}
|
||||
}
|
||||
|
||||
func WithAddress(addr string) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.Address = addr
|
||||
}
|
||||
}
|
||||
|
||||
func WithSessionStore(store sessions.Store) OptionFunc {
|
||||
return func(opts *Options) {
|
||||
opts.SessionStore = store
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user