Open barchard opened 3 years ago
Can you explain what you mean exactly?
Sure, I want to map /folder
to a /path/to/folder/on/disk
so that /folder/sub-folder/file.txt
automatically routes to /path/to/folder/on/disk/sub-folder/file.txt
So you're just wanting a file server essentially.
Interesting. I suspect I could lean on the built in PHP server's fileserver functionality. I'll need to investigate.
@ellipsis-dev
I was able to create an implementation plan for the requested feature, but I didn't have time to finish. The plan includes modifying the setResponseOfPath
method in src/MockWebServer.php
to map a URL path to a file path on the server, and updating the tests to cover this new functionality. I would appreciate any feedback or suggestions for improving the plan. Thank you.
setResponseOfPath
method in src/MockWebServer.php
Modify the setResponseOfPath
method to map a URL path to a file path on the server. This involves changing how the method stores the response for a given path. Instead of storing a response object, it should store a file path. When the server receives a request for a path, it should read the file at the corresponding file path and return its contents as the response. Make sure to handle different types of files correctly: if the file is a PHP script, execute it and return the output; if it's a non-PHP file, return the file directly. Also implement error handling for cases when the file doesn't exist or the server fails to read the file.
src/MockWebServer.php
Update the existing tests to cover the changes made to the setResponseOfPath
method. This includes tests that verify that a URL path is correctly mapped to a file path on the server and that the server returns the correct response when a request is made to the mapped URL path. Also add tests to cover error and edge cases, such as when the requested file doesn't exist or the server fails to read the file. Make sure to run the entire test suite after making these changes to ensure that the changes do not break existing functionality.
For more information about Ellipsis, check the documentation.
@ellipsis-dev give it a shot
I was able to create a partial implementation plan for the requested feature, but I didn't have time to finish. The plan includes modifying the setResponseOfPath
method in src/MockWebServer.php
to map a URL path to a file path on the server, and updating the tests to cover this new functionality. I would appreciate any feedback or suggestions for improving the plan. Thank you.
[No tentative implementation steps.]
For more information about Ellipsis, check the documentation.
Is it possible to support a base path for routes? This can then be mapped to a base file path for wild card routes
thanks