Skip to content

Commit 1722e47

Browse files
committed
update for addResourceRoute
1 parent e8d4098 commit 1722e47

File tree

6 files changed

+34
-26
lines changed

6 files changed

+34
-26
lines changed

_posts/2015-03-17-static-files.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ For example:
1919

2020
```java
2121
Pippo pippo = new Pippo();
22-
pippo.getApplication().GET(new PublicResourceHandler());
23-
pippo.getApplication().GET(new WebjarsResourceHandler());
22+
pippo.getApplication().addPublicResourceRoute();
23+
pippo.getApplication().addWebjarsResourceRoute();
2424
```
2525

26-
You can use multiple `FileResourceHandler` but it is nonsense to use more `PublicResourceHandler` or more `WebjarsResourceHandler`.
26+
or more verbose:
27+
28+
```java
29+
Pippo pippo = new Pippo();
30+
pippo.getApplication().addResourceRoute(new PublicResourceRoute());
31+
pippo.getApplication().addResourceRoute(new WebjarsResourceRoute());
32+
```
33+
34+
You can use multiple `FileResourceRoute` but it is nonsense to use more `PublicResourceRoute` or more `WebjarsResourceRoute`.
2735

2836
The [CrudNgDemo]({{ site.demourl }}/pippo-demo-crudng) (demo pippo-angularjs integration) is a good application that demonstrates the concept of static files.
2937
In `src/main/resources` we created a folder __public__ and we put all assets in that folder (imgs, css, js, fonts, ...).
@@ -75,12 +83,12 @@ Sure in your pom.xml file (if you use Maven) you must declare the dependencies t
7583
</dependency>
7684
```
7785

78-
If you want to serve static files that are not on the classpath then you may use the `FileResourceHandler`.
86+
If you want to serve static files that are not on the classpath then you may use the `FileResourceRoute`.
7987

8088
```java
8189
Pippo pippo = new Pippo();
8290
// make available some files from a local folder (try a request like 'src/main/resources/simplelogger.properties')
83-
pippo.getApplication().GET(new FileResourceHandler("/src", "src"));
91+
pippo.getApplication().addFileResourceRoute("/src", "src");
8492
```
8593

86-
From security reason the `FileResourceHandler` doesn't serve resources from outside it's base directory by using relative paths such as `../../../private.txt`.
94+
From security reason the `FileResourceRoute` doesn't serve resources from outside it's base directory by using relative paths such as `../../../private.txt`.

_posts/2015-04-03-freemarker.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ pippo-freemarker supports context-aware url generation for your classpath resour
7676
<script src="${publicAt('js/main.js')}"></script>
7777
```
7878

79-
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceHandler` and/or a `PublicResourcehandler`.
79+
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceRoute` and/or a `PublicResourceRoute`.
8080

8181
```java
8282
public class MyApplication extends Application {
8383

8484
@Override
8585
protected void onInit() {
86-
// add classpath resource handlers
87-
GET(new WebjarsResourceHandler());
88-
GET(new PublicResourceHandler());
86+
// add routes for static content
87+
addPublicResourceRoute();
88+
addWebjarsResourceRoute();
8989
...
9090
}
9191

_posts/2015-04-03-groovy.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,16 @@ script(src: webjarsAt('bootstrap/3.3.1/js/bootstrap.min.js')) {}
7575
script(src: publicAt('js/main.js')) {}
7676
```
7777

78-
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceHandler` and/or a `PublicResourcehandler`.
78+
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceRoute` and/or a `PublicResourceRoute`.
7979

8080
```java
8181
public class MyApplication extends Application {
8282

8383
@Override
8484
protected void onInit() {
85-
// add classpath resource handlers
86-
GET(new WebjarsResourceHandler());
87-
GET(new PublicResourceHandler());
85+
// add routes for static content
86+
addPublicResourceRoute();
87+
addWebjarsResourceRoute();
8888
...
8989
}
9090

_posts/2015-04-03-jade.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,16 @@ script(src=pippo.webjarsAt('bootstrap/3.3.1/js/bootstrap.min.js'))
7676
script(src=pippo.publicAt('js/main.js'))
7777
```
7878

79-
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceHandler` and/or a `PublicResourcehandler`.
79+
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceRoute` and/or a `PublicResourceRoute`.
8080

8181
```java
8282
public class MyApplication extends Application {
8383

8484
@Override
8585
protected void onInit() {
86-
// add classpath resource handlers
87-
GET(new WebjarsResourceHandler());
88-
GET(new PublicResourceHandler());
86+
// add routes for static content
87+
addPublicResourceRoute();
88+
addWebjarsResourceRoute();
8989
...
9090
}
9191

_posts/2015-04-03-pebble.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ pippo-pebble supports context-aware url generation for your classpath resources
7979
{% endraw %}
8080
```
8181

82-
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceHandler` and/or a `PublicResourcehandler`.
82+
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceRoute` and/or a `PublicResourceRoute`.
8383

8484
```java
8585
public class MyApplication extends Application {
8686

8787
@Override
8888
protected void onInit() {
89-
// add classpath resource handlers
90-
GET(new WebjarsResourceHandler());
91-
GET(new PublicResourceHandler());
89+
// add routes for static content
90+
addPublicResourceRoute();
91+
addWebjarsResourceRoute();
9292
...
9393
}
9494

_posts/2015-04-03-trimou.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,16 @@ pippo-trimou supports context-aware url generation for your classpath resources
8484
{% endraw %}
8585
```
8686

87-
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceHandler` and/or a `PublicResourcehandler`.
87+
**NOTE:** Use of these methods require that you have registered a `WebjarsResourceRoute` and/or a `PublicResourceRoute`.
8888

8989
```java
9090
public class MyApplication extends Application {
9191

9292
@Override
9393
protected void onInit() {
94-
// add classpath resource handlers
95-
GET(new WebjarsResourceHandler());
96-
GET(new PublicResourceHandler());
94+
// add routes for static content
95+
addPublicResourceRoute();
96+
addWebjarsResourceRoute();
9797
...
9898
}
9999

0 commit comments

Comments
 (0)