Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a DelegateHandler as a new module #59

Closed
ljucam opened this issue Jul 11, 2016 · 1 comment
Closed

Implement a DelegateHandler as a new module #59

ljucam opened this issue Jul 11, 2016 · 1 comment

Comments

@ljucam
Copy link
Collaborator

ljucam commented Jul 11, 2016

Implement the delegate feature. With this mechanism we are able to replace a request by another.
For example, we could make a GET that will be replaced by another one (or even a POST). This allows for creating cheap adapters.

Cookbook for the delegate:
Name a delegate:
/gateleen/server/delegate/v1/delegates/<delegate>/

Create a definition:
/gateleen/server/delegate/v1/delegates/<delegate>/definition

DelegateHandler automatically checks if the Pattern
/gateleen/server/delegate/v1/delegates/<delegate>/execution
is called.

Example:

 // create a delegate
PUT /gateleen/server/delegate/v1/delegates/user-zip-copy/definition
{
    "methods": [ "PUT", "DELETE" ],
    "pattern": ".*/([^/]+.*)",
    "requests": [
        {
            "method": "POST",
            "url": "/gateleen/server/v1/copy",
            "payload": {
                "source": "/gateleen/$1?expand=100&zip=true",
                "destination": "/gateleen/zips/users/$1.zip"
            }
        }
        ]
    }
}

// create a hook triggering the delegate
PUT /gateleen/users/_hooks/listeners/user-zip-copy
{
    "destination": "/gateleen/server/delegate/v1/delegates/user-zip-copy/execution"
}
@lbovet
Copy link
Member

lbovet commented Jul 19, 2016

As discussed, the delegate requests must be called synchronously. It is up to the delegate configuration to use a queue if async requests is wanted.
Also, the response of the last delegate request must be returned (status, headers, body).
In case of multiple delegate requests, if one fails, the following ones are not tried and the response of the failing one is returned to the caller.

@lbovet lbovet closed this as completed in 9c9e2f8 Jul 19, 2016
lbovet added a commit that referenced this issue Jul 19, 2016
Implement a DelegateHandler as a new module fixes #59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants