github.com/searKing/golang/go@v1.2.117/net/http/reject_insecure.option.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  package http
     6  
     7  import "log"
     8  
     9  // RejectInsecureWithErrorLog specifies an optional logger for errors
    10  func RejectInsecureWithErrorLog(l *log.Logger) RejectInsecureOption {
    11  	return RejectInsecureOptionFunc(func(r *rejectInsecure) {
    12  		r.ErrorLog = l
    13  	})
    14  }
    15  
    16  // RejectInsecureWithForceHttp specifies whether to allow any request, as a shortcut circuit
    17  func RejectInsecureWithForceHttp(forceHttp bool) RejectInsecureOption {
    18  	return RejectInsecureOptionFunc(func(r *rejectInsecure) {
    19  		r.ForceHttp = forceHttp
    20  	})
    21  }
    22  
    23  // RejectInsecureWithAllowedTlsCidrs specifies whether to allow any request which client or proxy's ip included
    24  // a cidr is a CIDR notation IP address and prefix length,
    25  // like "192.0.2.0/24" or "2001:db8::/32", as defined in
    26  // RFC 4632 and RFC 4291.
    27  func RejectInsecureWithAllowedTlsCidrs(allowedTLSCIDRs []string) RejectInsecureOption {
    28  	return RejectInsecureOptionFunc(func(r *rejectInsecure) {
    29  		r.AllowedTlsCidrs = allowedTLSCIDRs
    30  	})
    31  }
    32  
    33  // RejectInsecureWithWhitelistedPaths specifies whether to allow any request which http path matches
    34  func RejectInsecureWithWhitelistedPaths(whitelistedPaths []string) RejectInsecureOption {
    35  	return RejectInsecureOptionFunc(func(r *rejectInsecure) {
    36  		r.WhitelistedPaths = whitelistedPaths
    37  	})
    38  }