Skip to content

Commit

Permalink
Show mapping root as well
Browse files Browse the repository at this point in the history
  • Loading branch information
johanandren committed Feb 12, 2025
1 parent bbcb842 commit 0f78ded
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/src/modules/java/pages/http-endpoints.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,10 @@ This can be done for a single filename:
----
include::example$doc-snippets/src/main/java/com/example/api/StaticResourcesEndpoint.java[tag=single-static-resource-from-classpath]
----
<1> The specific path `/index.html`
<1> The specific path `/`
<2> Load a specific file placed in `src/main/resources/static-resources/index.html`
<3> Another specific path `/favicon.ico`
<4> The specific resource to serve

It is also possible to map an entire path subtree using `**` as a wildcard at the end of the path:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ public class StaticResourcesEndpoint {

// provide a landing page from root
// tag::single-static-resource-from-classpath[]
@Get("/index.html") // <1>
@Get("/") // <1>
public HttpResponse index() {
return HttpResponses.staticResource("index.html"); // <2>
}

@Get("/favicon.ico") // <3>
public HttpResponse favicon() {
return HttpResponses.staticResource("favicon.ico"); // <4>

}
// end::single-static-resource-from-classpath[]

// map in all the available packaged static resources under /static
Expand Down
Binary file not shown.

0 comments on commit 0f78ded

Please sign in to comment.