github.com/kubearmor/cilium@v1.6.12/api/v1/health/server/configure_cilium_health.go (about)

     1  // This file is safe to edit. Once it exists it will not be overwritten
     2  
     3  package server
     4  
     5  import (
     6  	"crypto/tls"
     7  	"net/http"
     8  
     9  	errors "github.com/go-openapi/errors"
    10  	runtime "github.com/go-openapi/runtime"
    11  	middleware "github.com/go-openapi/runtime/middleware"
    12  
    13  	"github.com/cilium/cilium/api/v1/health/server/restapi"
    14  	"github.com/cilium/cilium/api/v1/health/server/restapi/connectivity"
    15  )
    16  
    17  //go:generate swagger generate server --target ../../health --name CiliumHealth --spec ../openapi.yaml --api-package restapi --server-package server --default-scheme unix
    18  
    19  func configureFlags(api *restapi.CiliumHealthAPI) {
    20  	// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
    21  }
    22  
    23  func configureAPI(api *restapi.CiliumHealthAPI) http.Handler {
    24  	// configure the api here
    25  	api.ServeError = errors.ServeError
    26  
    27  	// Set your custom logger if needed. Default one is log.Printf
    28  	// Expected interface func(string, ...interface{})
    29  	//
    30  	// Example:
    31  	// api.Logger = log.Printf
    32  
    33  	api.JSONConsumer = runtime.JSONConsumer()
    34  
    35  	api.JSONProducer = runtime.JSONProducer()
    36  
    37  	if api.GetHealthzHandler == nil {
    38  		api.GetHealthzHandler = restapi.GetHealthzHandlerFunc(func(params restapi.GetHealthzParams) middleware.Responder {
    39  			return middleware.NotImplemented("operation .GetHealthz has not yet been implemented")
    40  		})
    41  	}
    42  	if api.ConnectivityGetStatusHandler == nil {
    43  		api.ConnectivityGetStatusHandler = connectivity.GetStatusHandlerFunc(func(params connectivity.GetStatusParams) middleware.Responder {
    44  			return middleware.NotImplemented("operation connectivity.GetStatus has not yet been implemented")
    45  		})
    46  	}
    47  	if api.ConnectivityPutStatusProbeHandler == nil {
    48  		api.ConnectivityPutStatusProbeHandler = connectivity.PutStatusProbeHandlerFunc(func(params connectivity.PutStatusProbeParams) middleware.Responder {
    49  			return middleware.NotImplemented("operation connectivity.PutStatusProbe has not yet been implemented")
    50  		})
    51  	}
    52  
    53  	api.ServerShutdown = func() {}
    54  
    55  	return setupGlobalMiddleware(api.Serve(setupMiddlewares))
    56  }
    57  
    58  // The TLS configuration before HTTPS server starts.
    59  func configureTLS(tlsConfig *tls.Config) {
    60  	// Make all necessary changes to the TLS configuration here.
    61  }
    62  
    63  // As soon as server is initialized but not run yet, this function will be called.
    64  // If you need to modify a config, store server instance to stop it individually later, this is the place.
    65  // This function can be called multiple times, depending on the number of serving schemes.
    66  // scheme value will be set accordingly: "http", "https" or "unix"
    67  func configureServer(s *http.Server, scheme, addr string) {
    68  }
    69  
    70  // The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
    71  // The middleware executes after routing but before authentication, binding and validation
    72  func setupMiddlewares(handler http.Handler) http.Handler {
    73  	return handler
    74  }
    75  
    76  // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
    77  // So this is a good place to plug in a panic handling middleware, logging and metrics
    78  func setupGlobalMiddleware(handler http.Handler) http.Handler {
    79  	return handler
    80  }