github.com/searKing/golang/go@v1.2.74/net/http/handlerinterceptorchain_options.go (about)

     1  // Code generated by "go-option -type HandlerInterceptorChain"; DO NOT EDIT.
     2  
     3  package http
     4  
     5  var _default_HandlerInterceptorChain_value = func() (val HandlerInterceptorChain) { return }()
     6  
     7  // A HandlerInterceptorChainOption sets options.
     8  type HandlerInterceptorChainOption interface {
     9  	apply(*HandlerInterceptorChain)
    10  }
    11  
    12  // EmptyHandlerInterceptorChainOption does not alter the configuration. It can be embedded
    13  // in another structure to build custom options.
    14  //
    15  // This API is EXPERIMENTAL.
    16  type EmptyHandlerInterceptorChainOption struct{}
    17  
    18  func (EmptyHandlerInterceptorChainOption) apply(*HandlerInterceptorChain) {}
    19  
    20  // HandlerInterceptorChainOptionFunc wraps a function that modifies HandlerInterceptorChain into an
    21  // implementation of the HandlerInterceptorChainOption interface.
    22  type HandlerInterceptorChainOptionFunc func(*HandlerInterceptorChain)
    23  
    24  func (f HandlerInterceptorChainOptionFunc) apply(do *HandlerInterceptorChain) {
    25  	f(do)
    26  }
    27  
    28  // sample code for option, default for nothing to change
    29  func _HandlerInterceptorChainOptionWithDefault() HandlerInterceptorChainOption {
    30  	return HandlerInterceptorChainOptionFunc(func(*HandlerInterceptorChain) {
    31  		// nothing to change
    32  	})
    33  }
    34  
    35  func (o *HandlerInterceptorChain) ApplyOptions(options ...HandlerInterceptorChainOption) *HandlerInterceptorChain {
    36  	for _, opt := range options {
    37  		if opt == nil {
    38  			continue
    39  		}
    40  		opt.apply(o)
    41  	}
    42  	return o
    43  }