github.com/songzhibin97/gkit@v1.2.13/page_token/option.go (about) 1 package page_token 2 3 import ( 4 "time" 5 6 "github.com/songzhibin97/gkit/encrypt/aes" 7 8 "github.com/songzhibin97/gkit/options" 9 ) 10 11 func SetMaxIndex(max int) options.Option { 12 return func(o interface{}) { 13 if t, ok := o.(*token); ok { 14 t.maxIndex = max 15 } 16 } 17 } 18 19 func SetMaxElements(max int) options.Option { 20 return func(o interface{}) { 21 if t, ok := o.(*token); ok { 22 t.maxElements = max 23 } 24 } 25 } 26 27 func SetSalt(salt string) options.Option { 28 return func(o interface{}) { 29 if t, ok := o.(*token); ok { 30 t.salt = aes.PadKey(salt) 31 } 32 } 33 } 34 35 func SetTimeLimitation(d time.Duration) options.Option { 36 return func(o interface{}) { 37 if t, ok := o.(*token); ok { 38 t.timeLimitation = d 39 } 40 } 41 }