github.com/searKing/golang/go@v1.2.117/net/mux/server_options.go (about) 1 // Copyright 2020 The searKing Author. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated by "go-option -type Server"; DO NOT EDIT. 6 7 package mux 8 9 var _default_Server_value = func() (val Server) { return }() 10 11 // A ServerOption sets options. 12 type ServerOption interface { 13 apply(*Server) 14 } 15 16 // EmptyServerOption does not alter the configuration. It can be embedded 17 // in another structure to build custom options. 18 // 19 // This API is EXPERIMENTAL. 20 type EmptyServerOption struct{} 21 22 func (EmptyServerOption) apply(*Server) {} 23 24 // ServerOptionFunc wraps a function that modifies Server into an 25 // implementation of the ServerOption interface. 26 type ServerOptionFunc func(*Server) 27 28 func (f ServerOptionFunc) apply(do *Server) { 29 f(do) 30 } 31 32 // sample code for option, default for nothing to change 33 func _ServerOptionWithDefault() ServerOption { 34 return ServerOptionFunc(func(*Server) { 35 // TODO nothing to change 36 }) 37 } 38 39 func (srv *Server) ApplyOptions(options ...ServerOption) *Server { 40 for _, opt := range options { 41 if opt == nil { 42 continue 43 } 44 opt.apply(srv) 45 } 46 return srv 47 }