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