-
Notifications
You must be signed in to change notification settings - Fork 4
/
route_options.go
57 lines (49 loc) · 1.15 KB
/
route_options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) Jim Lambert
// SPDX-License-Identifier: MIT
package gldap
type routeOptions struct {
withLabel string
withBaseDN string
withFilter string
withScope Scope
}
func routeDefaults() routeOptions {
return routeOptions{}
}
func getRouteOpts(opt ...Option) routeOptions {
opts := routeDefaults()
applyOpts(&opts, opt...)
return opts
}
// WithLabel specifies an optional label for the route
func WithLabel(l string) Option {
return func(o interface{}) {
if o, ok := o.(*routeOptions); ok {
o.withLabel = l
}
}
}
// WithBaseDN specifies an optional base DN to associate with a Search route
func WithBaseDN(dn string) Option {
return func(o interface{}) {
if o, ok := o.(*routeOptions); ok {
o.withBaseDN = dn
}
}
}
// WithFilter specifies an optional filter to associate with a Search route
func WithFilter(filter string) Option {
return func(o interface{}) {
if o, ok := o.(*routeOptions); ok {
o.withFilter = filter
}
}
}
// WithScope specifies and optional scope to associate with a Search route
func WithScope(s Scope) Option {
return func(o interface{}) {
if o, ok := o.(*routeOptions); ok {
o.withScope = s
}
}
}