41 lines
920 B
Go
41 lines
920 B
Go
package http
|
|
|
|
import "time"
|
|
|
|
type LocalHandlerOptions struct {
|
|
RoutePrefix string
|
|
Accounts []LocalAccount
|
|
CookieDomain string
|
|
CookieDuration time.Duration
|
|
}
|
|
|
|
type LocalHandlerOptionFunc func(*LocalHandlerOptions)
|
|
|
|
func defaultLocalHandlerOptions() *LocalHandlerOptions {
|
|
return &LocalHandlerOptions{
|
|
RoutePrefix: "",
|
|
Accounts: make([]LocalAccount, 0),
|
|
CookieDomain: "",
|
|
CookieDuration: 24 * time.Hour,
|
|
}
|
|
}
|
|
|
|
func WithAccounts(accounts ...LocalAccount) LocalHandlerOptionFunc {
|
|
return func(opts *LocalHandlerOptions) {
|
|
opts.Accounts = accounts
|
|
}
|
|
}
|
|
|
|
func WithRoutePrefix(prefix string) LocalHandlerOptionFunc {
|
|
return func(opts *LocalHandlerOptions) {
|
|
opts.RoutePrefix = prefix
|
|
}
|
|
}
|
|
|
|
func WithCookieOptions(domain string, duration time.Duration) LocalHandlerOptionFunc {
|
|
return func(opts *LocalHandlerOptions) {
|
|
opts.CookieDomain = domain
|
|
opts.CookieDuration = duration
|
|
}
|
|
}
|