-
Notifications
You must be signed in to change notification settings - Fork 209
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
Support multifile middleware #713
Comments
Hi, any updates on this? Is there any plan to add this support? |
@tommysitu would this be an option to create an additional flag to hoverctl like {
"entrypoint": "main.js"
}
hoverctl would zip this directory and send it over to hoverfly. hoverfly would unzip it to a temp directory and set its middleware binary to the one passed with if that seems ok, i can dig deeper. |
@ns3777k thanks for looking into this. But I think the problem is that some multi-file scripts may not work after being moved to a temp folder due to file path changes. However if this is not an issue, we can add something simple to support it, as you mentioned, a new flag to support loading a directory. For the entry point, you can just pass it through the For example:
where Provided all the files don't reference each other with an absolute path, they should be ok after being moved as well, but I could be too optimistic. |
Currently, when setting middleware, Hoverfly expects one file to be set as your script. This means any middleware that is split over multiple files is currently incompatible with Hoverfly.
An example of this came up in #557 with a user trying to import another file in Javascript, although this issue is not specfic to JavaScript.
Right now, the script Hoverfly takes in is very basic, hoverctl will read the script and send its contents over HTTP, allowing Hoverfly to persist it. In the past Hoverfly worked on hard path to the script. For a while now though, Hoverfly has written the script to the tmp dir. During this setting process, the script loses the filename. Making things a slightly more complicated.
Workarounds
A workaround to this issue is to convert your multifile middleware into a HTTP server, run that in parallel to Hoverfly and configure Hoverfly with remote middleware, pointing to your localhost middleware HTTP server. The complexity of this workaround is dependant on your language choice. Languages such as Python, Go NodeJS are the easiest to convert into HTTP middleware servers.
The text was updated successfully, but these errors were encountered: