Documentation ¶
Index ¶
- type CanHandle
- type CanHandlePrefix
- type CanHandleWithPrefix
- type Endpoint
- type SpecProxier
- func (s *SpecProxier) HandleDiscovery(w http.ResponseWriter, r *http.Request)
- func (s *SpecProxier) HandleGroupVersion(w http.ResponseWriter, r *http.Request)
- func (s *SpecProxier) InstallV2(server CanHandle)
- func (s *SpecProxier) InstallV3(server CanHandleWithPrefix)
- func (s *SpecProxier) Register(handler http.Handler) error
- func (s *SpecProxier) RegisterRoot(v3Root *handler3.OpenAPIV3Discovery, handler http.Handler)
- func (s *SpecProxier) V3Root() handler3.OpenAPIV3Discovery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CanHandle ¶
CanHandle defines an interface for resources that can handle http paths via a passed path and handler
type CanHandlePrefix ¶
CanHandlePrefix defines an interface for resources that can handle http paths ending with "/" via a passed path and handler. This interface does not (cannot) enforce path ending with a "/", it is up to the implementation to do that.
type CanHandleWithPrefix ¶
type CanHandleWithPrefix interface { CanHandle CanHandlePrefix }
CanHandleWithPrefix defines an interface for resources that can both Handle() and HandlePrefix()
type Endpoint ¶
type Endpoint struct { Handler http.Handler DGV handler3.OpenAPIV3DiscoveryGroupVersion }
Endpoint stores the handler and DiscoveryGroupVersion for an OpenAPI v3 endpoint. This is used when calling SpecProxier.HandleGroupVersion to serve http via the http.Handler, as well as constructing openapi v3 discovery root via SpecProxier.HandleDiscovery
type SpecProxier ¶
SpecProxier either proxies or serves openapi spec. It is the proxy middleware between an aggregator and delegate api servers. The proxier does not itself perform proxying but rather relies on an http.Handler to do this
func (*SpecProxier) HandleDiscovery ¶
func (s *SpecProxier) HandleDiscovery(w http.ResponseWriter, r *http.Request)
HandleDiscovery returns either the openapi v3 root doc (with relative paths, etc.), or if the delegate doesn't support v3, it serves the v3 spec (which has been converted from v2 and stored)
func (*SpecProxier) HandleGroupVersion ¶
func (s *SpecProxier) HandleGroupVersion(w http.ResponseWriter, r *http.Request)
HandleGroupVersion returns either a proxied result from the delegate's openapi v3 handler for a specific path, or it serves up the specifically requested path from the saved v3Spec (converted from v2) in the case of the delegate not supporting openapi v3.
func (*SpecProxier) InstallV2 ¶
func (s *SpecProxier) InstallV2(server CanHandle)
InstallV2 installs the /openapi/v2 handler into a CanHandle implementation. Typically, the CanHandle is going to be a server.GenericAPIServer's Handler.NonGoRestfulMux
func (*SpecProxier) InstallV3 ¶
func (s *SpecProxier) InstallV3(server CanHandleWithPrefix)
InstallV3 installs the /openapi/v3 handler into a CanHandleWithPrefix implementation. Typically, the CanHandleWithPrefix is going to be a server.GenericAPIServer's Handler.NonGoRestfulMux
func (*SpecProxier) Register ¶
func (s *SpecProxier) Register(handler http.Handler) error
Register will attempt to register OpenAPI v2 & v3 spec for the passed handler. It is expected that v2 will always be available, but v3 may not be. In that case, v2 will be converted to v3 using openapiconv.ConvertV2ToV3 and then served directly. Otherwise if v3 is available, the discovery root will be downloaded and merged into the SpecProxier's discovery map
func (*SpecProxier) RegisterRoot ¶
func (s *SpecProxier) RegisterRoot(v3Root *handler3.OpenAPIV3Discovery, handler http.Handler)
RegisterRoot takes a v3 openapi root, and an http.Handler. Iterating over the paths in v3Root, the handler is registered as the handler for that path. This is how new v3 roots are merged into Discovery and later served via HandleDiscovery
func (*SpecProxier) V3Root ¶
func (s *SpecProxier) V3Root() handler3.OpenAPIV3Discovery
V3Root returns the OpenAPIV3Discovery struct stored by the SpecProxier