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

Enable user to write a custom code to generate a response #20

Closed
shubhendumadhukar opened this issue May 13, 2021 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request

Comments

@shubhendumadhukar
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Though with handlebars, user has an extensive capability to write conditions, run loops etc without writing a code, there might be some complex use cases where the user would need to write a custom code to generate a desired response.

Describe the solution you'd like
This can be implemented using a custom handlebar helper which can evaluate the code passed in via mock files and generate a desired response. Final implementation could look like following in a mock file:

HTTP/1.1 200 OK
X-Static-Header: Static-Value

{{code}}
function (request, logger) {
    var name = request.query.name;
    return {
        status: 201,
        headers: {
            "X-Dynamic-Header": "Dynamic-Value"
        },
        body: `{'greeting': 'Hello ${name}'}`
    }
}
{{/code}}

Describe alternatives you've considered
NA

Additional context
NA

@shubhendumadhukar shubhendumadhukar added the enhancement New feature or request label May 13, 2021
@shubhendumadhukar shubhendumadhukar self-assigned this May 13, 2021
@shubhendumadhukar shubhendumadhukar moved this from Low priority to Needs triage in Camouflage Issue Tracker May 13, 2021
@shubhendumadhukar shubhendumadhukar moved this from Needs triage to In Progress in Camouflage Issue Tracker May 14, 2021
@shubhendumadhukar shubhendumadhukar moved this from In Progress to Testing in Camouflage Issue Tracker May 14, 2021
@shubhendumadhukar shubhendumadhukar moved this from Testing to In Progress in Camouflage Issue Tracker May 14, 2021
@shubhendumadhukar shubhendumadhukar moved this from In Progress to Testing in Camouflage Issue Tracker May 14, 2021
@shubhendumadhukar shubhendumadhukar moved this from Testing to Closed in Camouflage Issue Tracker May 14, 2021
@shubhendumadhukar
Copy link
Contributor Author

shubhendumadhukar commented May 14, 2021

Implemented and tested in development branch. Will be available for production release in camouflage-server v0.2.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

1 participant