-
Notifications
You must be signed in to change notification settings - Fork 12
/
server_options.go
47 lines (37 loc) · 1.14 KB
/
server_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
// Copyright 2020 The searKing Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code generated by "go-option -type Server"; DO NOT EDIT.
package mux
var _default_Server_value = func() (val Server) { return }()
// A ServerOption sets options.
type ServerOption interface {
apply(*Server)
}
// EmptyServerOption does not alter the configuration. It can be embedded
// in another structure to build custom options.
//
// This API is EXPERIMENTAL.
type EmptyServerOption struct{}
func (EmptyServerOption) apply(*Server) {}
// ServerOptionFunc wraps a function that modifies Server into an
// implementation of the ServerOption interface.
type ServerOptionFunc func(*Server)
func (f ServerOptionFunc) apply(do *Server) {
f(do)
}
// sample code for option, default for nothing to change
func _ServerOptionWithDefault() ServerOption {
return ServerOptionFunc(func(*Server) {
// TODO nothing to change
})
}
func (srv *Server) ApplyOptions(options ...ServerOption) *Server {
for _, opt := range options {
if opt == nil {
continue
}
opt.apply(srv)
}
return srv
}