Skip to content

Commit 5189c93

Browse files
committed
doc: intro + getting started
1 parent 4c37a44 commit 5189c93

File tree

9 files changed

+323
-0
lines changed

9 files changed

+323
-0
lines changed

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
out

docs/getting-started.adoc

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
== Getting Started
2+
3+
Add the dependency:
4+
5+
.maven:
6+
[source,xml,subs="normal"]
7+
----
8+
<dependency>
9+
<groupId>io.jooby</groupId>
10+
<artifactId>jooby-utow</artifactId>
11+
<version>{joobyVersion}</version>
12+
</dependency>
13+
----
14+
15+
.gradle:
16+
[source,gradle,subs="normal"]
17+
----
18+
compile 'io.jooby:jooby-utow:{joobyVersion}'
19+
----
20+
21+
[TIP]
22+
====
23+
We choose the http://undertow.io[Undertow] web server. Still Jooby is a multi-server web
24+
framework. You are free to choose between: link:server/jetty.html[Jetty],
25+
link:server/netty.html[Netty] and link:server/utow.html[Undertow].
26+
====
27+
28+
Write your application:
29+
30+
.App.java:
31+
[source, java]
32+
----
33+
import io.jooby.Jooby;
34+
35+
public class App extends Jooby {
36+
{
37+
get("/", ctx -> "Hello World!");
38+
}
39+
40+
public static void main(String[] args) {
41+
run(App::new, args);
42+
}
43+
}
44+
----
45+
46+
Run `App.java`:
47+
48+
[source]
49+
----
50+
INFO [2018-12-05 10:17:22,686] [main] App [utow@default]
51+
52+
GET /
53+
54+
listening on:
55+
http://localhost:8080
56+
----
57+
58+
`App.java` is ready {love}!
59+
60+
[TIP]
61+
====
62+
63+
Alternative you may want to try one of the starter projects:
64+
65+
- https://github.com/jooby-project/maven-starter[Maven starter]
66+
- https://github.com/jooby-project/gradle-starter[Gradle starter]
67+
- https://github.com/search?q=topic%3A2.x+org%3Ajooby-project&type=Repositories[All starter projects]
68+
====

docs/images/favicon96.png

8.42 KB
Loading

docs/images/logo.jpg

11.4 KB
Loading

docs/index.adoc

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
= Welcome to Jooby!
2+
:doctype: book
3+
:title: Jooby: do more! more easily!!
4+
:toc: left
5+
:toclevels: 3
6+
:sectanchors:
7+
:sectlinks:
8+
:sectnums:
9+
:linkattrs:
10+
:icons: font
11+
:source-language: asciidoc
12+
:imagesdir: images
13+
:source-highlighter: highlightjs
14+
:highlightjs-theme: agate
15+
:favicon: images/favicon96.png
16+
:joobyVersion: 2.0.0-Alpha1
17+
:love: &#10084;
18+
19+
////
20+
Style guidelines:
21+
22+
* Refer to the project in prose as simply Jooby, with no adornment or formatting. Enclose the class
23+
name `Jooby` in back ticks so readers can distinguish references to the `Jooby` class from
24+
references to the Jooby project as a whole.
25+
* 100 characters per line, except when you can't break it up e.g. links or asciidoc directives
26+
* Avoid class definition on Jooby code examples. Always start an example with `{...}`
27+
* Avoid JUnit boilerplate in code examples. Assertions are ok if they complement the example.
28+
* External links should use a caret at the end of the link title e.g.
29+
link:path/to/doc[the title^] so they open in separate tabs. See
30+
http://asciidoctor.org/docs/asciidoc-writers-guide/#target-window-and-role-attributes-for-links
31+
* Be funny. Nobody like reading dry documentation.
32+
* Be inclusive: keep usage of male and female names equal in code examples.
33+
* Best edited while drunk
34+
35+
////
36+
37+
== Introduction
38+
39+
Jooby is a modern, fun and easy to use web framework for Java built on top of your favorite web server.
40+
41+
.App.java
42+
[source,java]
43+
----
44+
public class App extends Jooby { // <1>
45+
46+
{
47+
get("/", ctx -> { // <2>
48+
return "Hello Jooby"; // <3>
49+
});
50+
}
51+
52+
public static void main(String[] args) {
53+
run(App::new, args); // <4>
54+
}
55+
}
56+
----
57+
<1> Create a new instance of `Jooby`
58+
<2> Define a route. A route consist of: a `HTTP method`, a `path pattern` and `handler` function
59+
<3> Returns `Hello Jooby` to the client
60+
<4> Initialize and run `App.java`
61+
62+
=== Status
63+
64+
[IMPORTANT]
65+
====
66+
There is no stable release yet for `2.0.0`. API may change between `alpha/beta` releases without
67+
warning.
68+
69+
This is a **work-in-progress** document and contains documentation and examples of what is ready to use. If it is not documented here, it is not implemented.
70+
71+
Not ready to play yet? Try https://jooby.org[Jooby 1.x]
72+
73+
Thank you {love}
74+
====
75+
76+
=== Micro and Fullstack
77+
78+
Jooby is a modular micro framework. At the core level:
79+
80+
- Reflection and annotation free
81+
- No dependency injection
82+
- Only HTTP Routing
83+
- Multi Server: link:server/jetty.html[Jetty], Netty, Undertow
84+
85+
Now, if you need more... Jooby don't leave you alone:
86+
87+
- Dependency injection via https://github.com/google/guice[Guice]
88+
- MVC programming model (subset of https://github.com/jax-rs[JAX-RS])
89+
- Extensive module ecosytem
90+
91+
=== Script API
92+
93+
Script API (a.k.a script routes) provides a fluent DSL, reflection and annotation free based on `lambda` functions.
94+
95+
We usually extends `Jooby` and define routes in the instance initializer:
96+
97+
.App.java
98+
[source,java]
99+
----
100+
public class App extends Jooby {
101+
102+
{
103+
get("/", ctx -> {
104+
return "Hello Jooby";
105+
});
106+
}
107+
108+
public static void main(String[] args) {
109+
run(App::new, args);
110+
}
111+
}
112+
----
113+
114+
This is not strictly necessary (of course), you may instantiate `Jooby` like:
115+
116+
.App.java
117+
[source,java]
118+
----
119+
public class App {
120+
121+
public static void main(String[] args) {
122+
run(() -> {
123+
Jooby app = new Jooby();
124+
125+
app.get("/", ctx -> {
126+
return "Hello Jooby";
127+
});
128+
}, args);
129+
}
130+
}
131+
----
132+
133+
=== MVC API
134+
135+
MVC API (a.k.a mvc routes) on the other hand uses annotation and reflection to define routes. Jooby
136+
implements a subset of https://github.com/jax-rs[JAX-RS] and it is not intended to be a fully
137+
https://github.com/jax-rs[JAX-RS] compliant.
138+
139+
.App.java
140+
[source,java]
141+
----
142+
public class App {
143+
144+
{
145+
use(new MyController());
146+
}
147+
148+
public static void main(String[] args) {
149+
run(App::new, args);
150+
}
151+
}
152+
----
153+
154+
.MyController.java
155+
[source,java]
156+
----
157+
public class MyController {
158+
159+
@GET
160+
public String hello() {
161+
return "Hello Jooby";
162+
}
163+
}
164+
----
165+
166+
[NOTE]
167+
====
168+
MVC API is not implemented yet.
169+
====
170+
171+
include::getting-started.adoc[]
172+
173+
174+

docs/module.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:doctype: book
2+
:toc: left
3+
:toclevels: 3
4+
:sectanchors:
5+
:sectlinks:
6+
:sectnums:
7+
:linkattrs:
8+
:icons: font
9+
:source-language: asciidoc
10+
:imagesdir: images
11+
:source-highlighter: highlightjs
12+
:highlightjs-theme: agate
13+
:favicon: images/favicon96.png

docs/pom.xml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
5+
6+
<parent>
7+
<groupId>io.jooby</groupId>
8+
<artifactId>jooby-project</artifactId>
9+
<version>2.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<modelVersion>4.0.0</modelVersion>
13+
<groupId>io.jooby</groupId>
14+
<artifactId>jooby-docs</artifactId>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>io.jooby</groupId>
19+
<artifactId>jooby</artifactId>
20+
<version>${jooby.version}</version>
21+
</dependency>
22+
</dependencies>
23+
24+
<build>
25+
<plugins>
26+
<plugin>
27+
<groupId>org.asciidoctor</groupId>
28+
<artifactId>asciidoctor-maven-plugin</artifactId>
29+
<version>1.5.7.1</version>
30+
<configuration>
31+
<sourceDirectory>${project.basedir}</sourceDirectory>
32+
<baseDir>${project.basedir}</baseDir>
33+
<outputDirectory>out</outputDirectory>
34+
<preserveDirectories>true</preserveDirectories>
35+
<backend>html</backend>
36+
<resources>
37+
<resource>
38+
<directory>.</directory>
39+
<excludes>
40+
<exclude>pom.xml</exclude>
41+
<exclude>*.iml</exclude>
42+
<exclude>out/**</exclude>
43+
<exclude>target/**</exclude>
44+
</excludes>
45+
</resource>
46+
</resources>
47+
</configuration>
48+
<executions>
49+
<execution>
50+
<id>html</id>
51+
<phase>generate-resources</phase>
52+
<goals>
53+
<goal>process-asciidoc</goal>
54+
</goals>
55+
</execution>
56+
</executions>
57+
</plugin>
58+
</plugins>
59+
</build>
60+
61+
</project>

docs/server/jetty.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include::module.adoc[]
2+
3+
== Jetty
4+
5+
Jetty web server implementation.

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<module>modules</module>
2121
<module>examples</module>
2222
<module>tests</module>
23+
<module>docs</module>
2324
</modules>
2425

2526
<licenses>

0 commit comments

Comments
 (0)