Package org.swisspush.gateleen.delegate
Class DelegateHandler
- java.lang.Object
-
- org.swisspush.gateleen.delegate.DelegateHandler
-
- All Implemented Interfaces:
org.swisspush.gateleen.core.logging.LoggableResource,org.swisspush.gateleen.core.refresh.Refreshable
public class DelegateHandler extends Object implements org.swisspush.gateleen.core.refresh.Refreshable, org.swisspush.gateleen.core.logging.LoggableResource
Allows to create delegates. E.g.
Definition of a delegate is stored in a resource calleddefinitionwithin the specified delegate.
PUT /gateleen/server/delegate/v1/delegates/user-zip-copy/definition{ "methods": [ "PUT", "DELETE" ], "pattern": "([^/]*)/(.*)", "requests": [ { "headers" : [], "uri": "/gateleen/server/copy", "method": "POST", "payload": { "source": "/gateleen/$1?expand=100&zip=true", "destination": "/gateleen/zips/users/$1.zip" } } ] }To trigger an execution, it suffice to perform a PUT request on the virtual collectionexecutionwithin the specified delegate.
PUT /gateleen/server/delegate/v1/delegates/user-zip-copy/execution/<...>- Author:
- https://github.com/ljucam [Mario Ljuca]
-
-
Constructor Summary
Constructors Constructor Description DelegateHandler(io.vertx.core.Vertx vertx, io.vertx.core.http.HttpClient selfClient, org.swisspush.gateleen.core.storage.ResourceStorage delegateStorage, String delegatesUri, Map<String,Object> properties, io.vertx.core.Handler<Void> doneHandler)Creates a new instance of the DelegateHandler.DelegateHandler(io.vertx.core.Vertx vertx, io.vertx.core.http.HttpClient selfClient, org.swisspush.gateleen.core.storage.ResourceStorage delegateStorage, String delegatesUri, Map<String,Object> properties, org.swisspush.gateleen.core.util.StatusCode unmatchedDelegateStatusCode, io.vertx.core.Handler<Void> doneHandler)Creates a new instance of the DelegateHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenableResourceLogging(boolean resourceLoggingEnabled)protected StringgetDelegateName(String uri)Tries to extract the name of the delegate out of the incoming uri.booleanhandle(io.vertx.core.http.HttpServerRequest request)Checks if the DelegateHandler is responsible for this request.voidinit()This method initializes the Handler.voidrefresh()
-
-
-
Constructor Detail
-
DelegateHandler
public DelegateHandler(io.vertx.core.Vertx vertx, io.vertx.core.http.HttpClient selfClient, org.swisspush.gateleen.core.storage.ResourceStorage delegateStorage, String delegatesUri, Map<String,Object> properties, io.vertx.core.Handler<Void> doneHandler)Creates a new instance of the DelegateHandler.- Parameters:
vertx- vertxselfClient- selfClientdelegateStorage- delegateStorage - only used for storing delegatesdelegatesUri- delegate rootproperties- propertiesdoneHandler- doneHandler
-
DelegateHandler
public DelegateHandler(io.vertx.core.Vertx vertx, io.vertx.core.http.HttpClient selfClient, org.swisspush.gateleen.core.storage.ResourceStorage delegateStorage, String delegatesUri, Map<String,Object> properties, @Nullable org.swisspush.gateleen.core.util.StatusCode unmatchedDelegateStatusCode, io.vertx.core.Handler<Void> doneHandler)Creates a new instance of the DelegateHandler.- Parameters:
vertx- vertxselfClient- selfClientdelegateStorage- delegateStorage - only used for storing delegatesdelegatesUri- delegate rootproperties- propertiesunmatchedDelegateStatusCode- respond requests with this status code when not matcheddoneHandler- doneHandler
-
-
Method Detail
-
init
public void init()
This method initializes the Handler. It should be called after the router is successfully established.
-
getDelegateName
protected String getDelegateName(String uri)
Tries to extract the name of the delegate out of the incoming uri.- Parameters:
uri- original request uri- Returns:
- the name of the delegate or null if nothing matches
-
handle
public boolean handle(io.vertx.core.http.HttpServerRequest request)
Checks if the DelegateHandler is responsible for this request. If so it processes the request and returns true, otherwise it returns false.- Parameters:
request- original request- Returns:
- true if processed, false otherwise
-
refresh
public void refresh()
- Specified by:
refreshin interfaceorg.swisspush.gateleen.core.refresh.Refreshable
-
enableResourceLogging
public void enableResourceLogging(boolean resourceLoggingEnabled)
- Specified by:
enableResourceLoggingin interfaceorg.swisspush.gateleen.core.logging.LoggableResource
-
-