gotta be careful here.

This commit is contained in:
Michael Quigley 2022-08-03 13:45:41 -04:00
parent cf49c10d87
commit 9bd7f6dba1
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -4,92 +4,27 @@ package rest_server_zrok
import ( import (
"crypto/tls" "crypto/tls"
"github.com/openziti-test-kitchen/zrok/ui"
"github.com/sirupsen/logrus"
"net/http" "net/http"
"github.com/go-openapi/errors" "github.com/go-openapi/errors"
"github.com/go-openapi/runtime" "github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/openziti-test-kitchen/zrok/rest_model_zrok"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations" "github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/identity"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/metadata"
"github.com/openziti-test-kitchen/zrok/rest_server_zrok/operations/tunnel"
) )
//go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model_zrok --server-package rest_server_zrok --principal rest_model_zrok.Principal --exclude-main //go:generate swagger generate server --target ../../zrok --name Zrok --spec ../specs/zrok.yml --model-package rest_model_zrok --server-package rest_server_zrok --principal interface{} --exclude-main
func configureFlags(api *operations.ZrokAPI) { func configureFlags(api *operations.ZrokAPI) {
// api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... } // api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{ ... }
} }
func configureAPI(api *operations.ZrokAPI) http.Handler { func configureAPI(api *operations.ZrokAPI) http.Handler {
// configure the api here
api.ServeError = errors.ServeError api.ServeError = errors.ServeError
api.Logger = logrus.Printf
// Set your custom logger if needed. Default one is log.Printf
// Expected interface func(string, ...interface{})
//
// Example:
// api.Logger = log.Printf
api.UseSwaggerUI() api.UseSwaggerUI()
// To continue using redoc as your UI, uncomment the following line
// api.UseRedoc()
api.JSONConsumer = runtime.JSONConsumer() api.JSONConsumer = runtime.JSONConsumer()
api.JSONProducer = runtime.JSONProducer() api.JSONProducer = runtime.JSONProducer()
// Applies when the "x-token" header is set
if api.KeyAuth == nil {
api.KeyAuth = func(token string) (*rest_model_zrok.Principal, error) {
return nil, errors.NotImplemented("api key auth (key) x-token from header param [x-token] has not yet been implemented")
}
}
// Set your custom authorizer if needed. Default one is security.Authorized()
// Expected interface runtime.Authorizer
//
// Example:
// api.APIAuthorizer = security.Authorized()
if api.IdentityCreateAccountHandler == nil {
api.IdentityCreateAccountHandler = identity.CreateAccountHandlerFunc(func(params identity.CreateAccountParams) middleware.Responder {
return middleware.NotImplemented("operation identity.CreateAccount has not yet been implemented")
})
}
if api.IdentityEnableHandler == nil {
api.IdentityEnableHandler = identity.EnableHandlerFunc(func(params identity.EnableParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation identity.Enable has not yet been implemented")
})
}
if api.MetadataListEnvironmentsHandler == nil {
api.MetadataListEnvironmentsHandler = metadata.ListEnvironmentsHandlerFunc(func(params metadata.ListEnvironmentsParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation metadata.ListEnvironments has not yet been implemented")
})
}
if api.IdentityLoginHandler == nil {
api.IdentityLoginHandler = identity.LoginHandlerFunc(func(params identity.LoginParams) middleware.Responder {
return middleware.NotImplemented("operation identity.Login has not yet been implemented")
})
}
if api.TunnelTunnelHandler == nil {
api.TunnelTunnelHandler = tunnel.TunnelHandlerFunc(func(params tunnel.TunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation tunnel.Tunnel has not yet been implemented")
})
}
if api.TunnelUntunnelHandler == nil {
api.TunnelUntunnelHandler = tunnel.UntunnelHandlerFunc(func(params tunnel.UntunnelParams, principal *rest_model_zrok.Principal) middleware.Responder {
return middleware.NotImplemented("operation tunnel.Untunnel has not yet been implemented")
})
}
if api.MetadataVersionHandler == nil {
api.MetadataVersionHandler = metadata.VersionHandlerFunc(func(params metadata.VersionParams) middleware.Responder {
return middleware.NotImplemented("operation metadata.Version has not yet been implemented")
})
}
api.PreServerShutdown = func() {} api.PreServerShutdown = func() {}
api.ServerShutdown = func() {} api.ServerShutdown = func() {}
@ -118,5 +53,6 @@ func setupMiddlewares(handler http.Handler) http.Handler {
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document. // The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logging and metrics. // So this is a good place to plug in a panic handling middleware, logging and metrics.
func setupGlobalMiddleware(handler http.Handler) http.Handler { func setupGlobalMiddleware(handler http.Handler) http.Handler {
return handler logrus.Infof("configuring")
return ui.StaticBuilder(handler)
} }