Class ProxyRegistry
- Since:
- 3.9.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents a constructor for aHTTPClient. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddHTTPEngineSelector(Function<org.omegazero.net.socket.SocketConnection, Class<? extends HTTPEngine>> selector) Registers a newHTTPEngineselector.Returns the default error document.Returns the error document set for the given type.getErrdocForAccept(String accept) Parses the given value of an Accept HTTP header and returns theHTTPErrdocfor the first content type in the header for which an error document is found.getHTTPClientALPName(String name) Returns the application layer protocol name for the given protocol name.Returns a constructor of aHTTPClientimplementation for the given protocol name.voidregisterClientManager(String id, org.omegazero.net.client.NetClientManager mgr) Registers a newNetClientManagerfor outgoing connections.voidregisterHTTPClientImplementation(String name, ProxyRegistry.HTTPClientConstructor constructor, String alpName) Registers a newHTTPClientimplementation for outgoing HTTP requests.voidregisterServerInstance(Class<? extends org.omegazero.net.server.NetServer> c) Registers a newNetServerinstance of the given type.voidregisterServerInstance(org.omegazero.net.server.NetServer server) Registers a newNetServerinstance.voidsetErrdoc(String type, HTTPErrdoc errdoc) Sets an error document for the given MIME type (Content-Type header in HTTP).
-
Method Details
-
registerServerInstance
Registers a newNetServerinstance of the given type.A new instance of the given type is created and registered using
registerServerInstance(NetServer). This requires that the given type has a constructor with no parameters. If the type requires additional arguments in the constructor, useProxy.registerServerInstance(NetServer)directly instead.- Parameters:
c- The server class- Throws:
IllegalStateException- If this method is called after the INIT phase
-
registerServerInstance
public void registerServerInstance(org.omegazero.net.server.NetServer server) Registers a newNetServerinstance. The instance is added to the list of registered instances and will be initialized at the end of the main initialization phase, meaning server instances must be registered during theProxyEvents.PREINITorProxyEvents.INITevent.- Parameters:
server- The server instance- Throws:
IllegalStateException- If this method is called after the INIT phase
-
registerClientManager
Registers a newNetClientManagerfor outgoing connections.- Parameters:
id- The identifier for the client managermgr- The client manager- Throws:
IllegalArgumentException- If a client manager with the given id already exists
-
addHTTPEngineSelector
public void addHTTPEngineSelector(Function<org.omegazero.net.socket.SocketConnection, Class<? extends HTTPEngine>> selector) Registers a newHTTPEngineselector.For incoming connections, an appropriate
HTTPEnginemust be selected. For this, every registered selector is called until one returns a non-nullvalue, which will be theHTTPEngineused for the connection. If all selectors returnnull, anUnsupportedOperationExceptionis thrown and the connection will be closed.- Parameters:
selector- The selector
-
registerHTTPClientImplementation
public void registerHTTPClientImplementation(String name, ProxyRegistry.HTTPClientConstructor constructor, String alpName) Registers a newHTTPClientimplementation for outgoing HTTP requests.The constructor of a
HTTPClientreceives theSocketConnectionof the client and the targetUpstreamServerthe client should connect to.- Parameters:
name- The protocol nameconstructor- The constructoralpName- The application layer protocol name- Throws:
IllegalArgumentException- If an HTTP client implementation with the given name already exists
-
getHTTPClientImplementation
Returns a constructor of aHTTPClientimplementation for the given protocol name.- Parameters:
name- The protocol name- Returns:
- The constructor, or
nullif no implementation for the given protocol name exists - See Also:
-
getHTTPClientALPName
Returns the application layer protocol name for the given protocol name.- Parameters:
name- The protocol name- Returns:
- The name used in ALPN negotiation, or
nullif no implementation for the given protocol name exists - See Also:
-
setErrdoc
Sets an error document for the given MIME type (Content-Type header in HTTP).The error document is returned by
getErrdoc(String)when given the MIME type. TheHTTPEngineimplementation may choose any way to determine the appropriate error document type for a request, but usually does so using the Accept HTTP request header.- Parameters:
type- The content type to set this error document forerrdoc- The error document
-
getErrdoc
Returns the error document set for the given type. If no error document for the given type was set usingsetErrdoc(String, HTTPErrdoc), the default error document is returned (getDefaultErrdoc()).- Parameters:
type- The MIME type of the error document- Returns:
- An error document of the given MIME type or the default error document if none was found
- See Also:
-
getDefaultErrdoc
Returns the default error document. This is guaranteed to be non-null.- Returns:
- The default error document
-
getErrdocForAccept
Parses the given value of an Accept HTTP header and returns theHTTPErrdocfor the first content type in the header for which an error document is found. If no overlap is found, or the header does not exist (the given value isnull), the default error document is returned.- Parameters:
accept- The value of an Accept HTTP header- Returns:
- A suitable
HTTPErrdoc, or the default errdoc if none was found - See Also:
-