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

Trailing slash required on static content handlers, 2.4.1+ #1970

Open
arinban opened this issue Sep 8, 2017 · 5 comments
Open

Trailing slash required on static content handlers, 2.4.1+ #1970

arinban opened this issue Sep 8, 2017 · 5 comments

Comments

@arinban
Copy link

arinban commented Sep 8, 2017

Please see my comment on javaee/grizzly#1823 (closed). Wanted to make sure this issue got seen, so I opened a new one. Sorry if that's not the proper procedure.

@arinban
Copy link
Author

arinban commented Sep 15, 2017

@rlubke Commented
@jcalcote The fix implemented in #1823 hasn't changed. I've performed a simple test here and it appears to be working as expected.

Can you provide a small maven-based test case showing the issue?

@arinban
Copy link
Author

arinban commented Sep 18, 2017

@jcalcote Commented
Sorry it took so long to get back to you @rlubke. I think I know what's causing the problem. First, here's my sample application - it's just a maven project using the jersey-quickstart-grizzly2 archetype (for jersey 2.26).

The ONLY change I made was to replaced the last line in main as follows:

        HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);

        ClassLoader loader = Main.class.getClassLoader();
        CLStaticHttpHandler docsHandler = new CLStaticHttpHandler(loader, "html/");
        docsHandler.setFileCacheEnabled(false);
        server.getServerConfiguration().addHttpHandler(docsHandler, "/docs");

        return server;

Then I added a resource: /resources/html/index.html:

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"></head>
<body>Hi there!</body>
</html>

Hitting http://localhost:8080/myapp/myresource returns "Got it!"

Hitting http://localhost:8080/docs returns a grizzly error banner - black and yellow - "Not Found" in the title, "Resource identified by path '/docs', does not exist.", footer contains Grizzly 2.4.0.

Hitting http://localhost;8080/docs/ returns "Hi there!" - the content of the index.html page.

--John

@arinban
Copy link
Author

arinban commented Sep 19, 2017

@rlubke Commented
Though the end result is the same, this is a different issue.
The issue appears to be within the Mapper which is a picky code path. This will require a bit of time.

@arinban
Copy link
Author

arinban commented Sep 19, 2017

@jcalcote Commented
Thanks for looking into it - I have a work around for the moment - I really wanted my swagger docs to be at the root resource, so I just added a root resource in jersey that redirects to /docs/ - as long as people hit the root instead of the /docs path, they'll land in the right place.

@arinban
Copy link
Author

arinban commented Feb 3, 2018

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

1 participant