You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pippo.GET("/", routeContext -> routeContext.send("Hello World!"));// add a route
23
25
pippo.start();
24
26
}
25
27
26
28
}
27
29
```
28
30
31
+
Sure, the number of lines can decrease considerable if I use variant:
32
+
33
+
```java
34
+
publicclassHelloWorld {
35
+
36
+
publicstaticvoidmain(String[] args) {
37
+
Pippo.send("Hello World!");
38
+
}
39
+
40
+
}
41
+
```
42
+
if you consider that in first variant they are too many lines of code.
43
+
29
44
You can run _HelloWorld_ class from your IDE (or command line) as a normal (desktop) application.
30
45
The `default port` for embedded web server is __8338__ so open your internet browser and type `http://localhost:8338` to
31
46
see the result.
32
47
33
-
You can change some aspects of the embedded web server using `WebServerSettings`:
48
+
You can change some aspects (settings) of the embedded web server using:
49
+
50
+
```java
51
+
newPippo()
52
+
.setPort(8081) // change port to 8081
53
+
.start();
54
+
```
55
+
56
+
or
34
57
35
58
```java
36
59
Pippo pippo =newPippo();
37
-
pippo.getServer().getSettings().port(8081);
60
+
61
+
WebServer server = pippo.getServer(); // if you want a fine tuning of the web server
62
+
server.getSettings().port(8081);
63
+
server.setPippoFilterPath("/pippo/*");
64
+
38
65
pippo.start();
39
66
```
40
67
41
-
In above snippet I changed programmatically the port to _8081_.
42
-
43
68
Probably the best approach to specify the server port for an embedded server is via application settings.
44
69
Simple set the `server.port` variable from your `src\main\resources\main\conf\application.properties` with your value:
45
70
46
-
```
71
+
```properties
47
72
# Control the port that Pippo binds
48
73
server.port = 8081
49
74
```
50
75
51
-
Pippo detects automatically the template engine using __ServiceLoader__.
52
-
Pippo comes (out of the box) with some web servers:
76
+
Using the same `application.properties` you can change other server parameters like
77
+
78
+
```properties
79
+
# Control the network ip address Pippo binds
80
+
# Specify 0.0.0.0 for all available interfaces
81
+
server.host = localhost
82
+
83
+
# Specify the context path of the application
84
+
server.contextPath = /
85
+
86
+
# HTTPS
87
+
#server.keystoreFile =
88
+
#server.keystorePassword =
89
+
#server.truststoreFile =
90
+
```
91
+
92
+
By default, Pippo use context path `/` (root) but you can change it using
93
+
-`server.contextPath` property
94
+
- programmatically
95
+
```java
96
+
newPippo()
97
+
.setPort(8081)
98
+
.setFilterPath("/pippo/*") // <<<
99
+
.start();
100
+
```
101
+
102
+
Pippo detects automatically the web server using __ServiceLoader__.
103
+
If you want to use a web server in your application, you must add pippo-<servername> as dependency for your project.
104
+
Other option is to set programmatically the desired web server using `Pippo#setServer(WebServer server)`.
105
+
106
+
Pippo comes (out of the box) with some web servers (most popular):
53
107
54
108
-[Jetty](http://eclipse.org/jetty)`pippo-jetty`
55
109
-[Undertow](http://undertow.io)`pippo-undertow`
@@ -58,35 +112,24 @@ Pippo comes (out of the box) with some web servers:
58
112
59
113
To use one of these servers just add a dependency in your project:
60
114
61
-
```
115
+
```xml
62
116
<dependency>
63
-
<groupId>ro.pippo</groupId>
64
-
<artifactId>pippo-jetty</artifactId>
65
-
<version>${pippo.version}</version>
117
+
<groupId>ro.pippo</groupId>
118
+
<artifactId>pippo-jetty</artifactId>
119
+
<version>${pippo.version}</version>
66
120
</dependency>
67
121
```
68
122
69
-
If you need to create support for another embedded web server that is not implemented in Pippo or third-party modules
70
-
than all you need to do is to implement [WebServer]({{ site.coreurl }}/src/main/java/ro/pippo/core/WebServer.java) or to extends [AbstractWebServer]({{ site.coreurl }}/src/main/java/ro/pippo/core/AbstractWebServer.java).
71
-
72
-
If you want to make your embedded server plugable for Pippo than you must add `@MetaInfServices(WebServer.class)` annotation to
For the same task but using a more generic approach you can use `WebServerInitializer`.
126
181
Below I present you a code snippet that add a servlet to Pippo:
127
182
128
183
```java
@@ -178,8 +233,23 @@ public class ServletDemo {
178
233
179
234
}
180
235
```
181
-
DON'T forget to add `@MetaInfServices` on your implementation of `WebServerInitializer`!
236
+
__DON'T__ forget to add `@MetaInfServices` on your implementation of `WebServerInitializer`!
182
237
The full code is available in [pippo-demo-servlet]({{ site.demourl }}/pippo-demo-servlet) project.
183
238
184
-
A more complex demo project that shows you how to integrate [Jersey](https://jersey.java.net) is available in [pippo-demo-jersey]({{ site.demourl }}/pippo-demo-jersey) project.
185
-
This demo is the code source of the article `Pippo and Jersey (JAX-RS): A Match Made in Heaven` that is availables on [DZone](https://dzone.com/articles/pippo-and-jersey-jax-rs).
239
+
If you need to create support for another embedded web server that is not implemented in Pippo or third-party modules
240
+
than all you need to do is to implement [WebServer]({{ site.coreurl }}/src/main/java/ro/pippo/core/WebServer.java) or to extends [AbstractWebServer]({{ site.coreurl }}/src/main/java/ro/pippo/core/AbstractWebServer.java).
241
+
242
+
If you want to make your embedded server plugable for Pippo than you must add `@MetaInfServices(WebServer.class)` annotation to
A more complex demo project that shows you how to integrate [Jersey](https://jersey.java.net) is available in [pippo-demo-jersey]({{ site.demourl }}/pippo-demo-jersey) project.
255
+
This demo is the code source of the article `Pippo and Jersey (JAX-RS): A Match Made in Heaven` that is availables on [DZone](https://dzone.com/articles/pippo-and-jersey-jax-rs).
0 commit comments