-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
HandlebarsRegistrationCallback not fired #433
Comments
This is because you already use the |
Does this mean that you cannot use Handlebars if you use WithCallback()? If so I would really like this as a feature. |
I see your point. You want to use code like this? private static ResponseMessage DataSetCallback(RequestMessage arg)
{
return new ResponseMessage
{
BodyData = new BodyData
{
BodyAsJson = new
{
Test = "test: {{request.url}}"
}
},
StatusCode = 200
};
} |
Yes. Now I've implemented Handlebars myself in the callback function, but I'm missing the Wiremock handlebar extensions. If only I have access to the handlebars context (IHandebars) of Wiremock I'm good to go. Right now there is no way for me to achieve this. |
I've made a preview fix (can be found via MyGet) : |
Yes, that works. But is it not possible to expose the IHandlebars on the WireMockServer? I require that context somewhere else too. As I see it every request registers the handlebars again, that isn't really necessary right? |
Correct, the factory only needs to be created once, no need to create that for every response. I'll check if that's easy to change. And where do you need that IHandlebars ? Would it help if this was maybe available in callback? |
I managed to complete what I wanted by assigning the IHandlebars in the callback to a static property. I can now use this property wherever I want. I think the best way to do this is to init IHandlebars using the factory on startup and then expose it for everything to use. Now you have to await 1 transform cycle to have it working. |
I'm looking into the code to do some changes, but the HandlebarsRegistrationCallback is still fired with each response because every response gets a fresh handlebars-context. I'm not sure if I can change this. For now, I'll just fix your bug that the HandlebarsRegistrationCallback was never fired when using You can create a new issue with the specific issue, or try to make PR yourself. Linking #435 ... |
closing... |
WireMock.Handlebars.zip
See attached reproduction project. Start and go to http://localhost:5001/datasets
HandlebarsRegistrationCallback is not fired, so I can't register custom handlebar extensions.
The text was updated successfully, but these errors were encountered: