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

serve dir/index.html when browsing to dir/ #266

Closed
wants to merge 1 commit into from

Conversation

momolog
Copy link

@momolog momolog commented Nov 27, 2020

Very naive patch that should allow puma-dev to serve the public/index.html when browsing to /.

I added a passing test and did not break any existing so I am cautiously optimistic.
However I do not understand the original intention of the removed code

if reqPath == "/" {
  return false
}

@nonrational
Copy link
Member

I think this would produce unexpected behavior for most users. puma-dev's primary purpose is to serve apps with puma. As such, one would expect GET example.puma to serve the root route, not public/index.html

If you're intent on using puma-dev, I would suggest writing a small rack app to serve index.html via puma.

@momolog
Copy link
Author

momolog commented Nov 27, 2020

But I would argue that this is exactly how you would expect the public folder to take precedence!

E.g. when you add public/index.html to an existing rails project, browsing to / does display the index page instead of the controller action configured in root.
You could, in theory, have a Rails project, that just consists of a public folder full of static HTML files and no controller action.
When surfing this via rails s and browsing to http://localhost:3000/ an public/index.html will be served just fine.

When using puma-dev, this will break.
Actually, when using rails, it does work with puma-dev as well, which then must be a rails function.


Btw: This is how pow behaved, too: If there is an index.html, serve it, also when the dir is requested.

@momolog
Copy link
Author

momolog commented Nov 27, 2020

Let me explain the use case:

I used .pow for serving static sites (e.g. the output of static site generators) all the time. I generated the site and inside the top dir I added a symlink: ln -s . public.
Then by symlinking the directory into like cd ~/.pow; ln -s ~/static-sites/site . I could just go to site.dev and everything just worked.

Before .pow I had to fiddle around with /etc/apache2/extra/httpd-vhosts.conf for every site.

This use case is not supported by puma-dev anymore and I for one sorely miss it.

@nonrational
Copy link
Member

Thank you for explaining your usecase. Is configuring a Rack::Static app undesirable to support this feature? I believe you could use a standard file and link it via ln -s ~/static-sites/config.ru in each site sub-directory.

In the wake of issues like #260, I am somewhat reluctant to make puma-dev a "good" static site server, when better, more flexible and extensible behavior is already provided by Rack.

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

Successfully merging this pull request may close these issues.

2 participants