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

Base path for routes #32

Open
barchard opened this issue Aug 24, 2021 · 7 comments
Open

Base path for routes #32

barchard opened this issue Aug 24, 2021 · 7 comments

Comments

@barchard
Copy link

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

@donatj
Copy link
Owner

donatj commented Aug 30, 2021

Can you explain what you mean exactly?

@barchard
Copy link
Author

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

@donatj
Copy link
Owner

donatj commented Nov 29, 2021

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.

@donatj
Copy link
Owner

donatj commented May 9, 2024

@ellipsis-dev

Copy link
Contributor

ellipsis-dev bot commented May 9, 2024

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.

Implementation proposal (work in progress)

Step 1: Modify the 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.

Step 2: Update tests to cover new functionality in 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.

@donatj
Copy link
Owner

donatj commented May 9, 2024

@ellipsis-dev give it a shot

Copy link
Contributor

ellipsis-dev bot commented May 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants