go-captiveportal/rfc8908/option.go

52 lines
1.0 KiB
Go

package rfc8908
import "context"
type Options struct {
UserPortalURL string
VenueInfoURL string
CanExtendSession *bool
SecondsRemaining SecondsRemainingFunc
BytesRemaining BytesRemainingFunc
}
type OptionsFunc func(*Options)
type SecondsRemainingFunc func(context.Context) (*int, error)
type BytesRemainingFunc func(context.Context) (*int, error)
func DefaultOptions() *Options {
return &Options{}
}
func WithUserPortalURL(userPortalURL string) OptionsFunc {
return func(o *Options) {
o.UserPortalURL = userPortalURL
}
}
func WithVenueInfoURL(venueInfoURL string) OptionsFunc {
return func(o *Options) {
o.VenueInfoURL = venueInfoURL
}
}
func WithCanExtendSession(canExtend bool) OptionsFunc {
return func(o *Options) {
o.CanExtendSession = &canExtend
}
}
func WithSecondsRemainingFunc(fn SecondsRemainingFunc) OptionsFunc {
return func(o *Options) {
o.SecondsRemaining = fn
}
}
func WithBytesRemainingFunc(fn BytesRemainingFunc) OptionsFunc {
return func(o *Options) {
o.BytesRemaining = fn
}
}