1111 <a href="https://choosealicense.com/licenses/mit/"><img
1212 alt="License MIT"
1313 src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
14- <a href="https://github.com/Simonwep/java-express/releases"><img
15- alt="Java 8"
16- src="https://img.shields.io/badge/Java-8-E76E0D.svg"></a>
1714 <a href="https://docs.oracle.com/javase/8/"><img
1815 alt="Current version"
19- src="https://img.shields.io/badge/version-0 .0.10%20alpha -EB4D5C.svg"></a>
20- <a href="https://www.patreon.com/simonwep"><img
21- alt="Support me"
22- src="https://img.shields.io/badge/patreon-support-DF2D41.svg"></a>
16+ src="https://img.shields.io/badge/version-1 .0.0 -EB4D5C.svg"></a>
17+ <a href="https://www.patreon.com/simonwep"><img
18+ alt="Support me"
19+ src="https://img.shields.io/badge/patreon-support-DF2D41.svg"></a>
2320 <a href="https://gradle.org/"><img
2421 alt="Build with gradle"
2522 src="https://img.shields.io/badge/build%20with-gradle-006533.svg"></a>
2623 <a href="https://travis-ci.org/Simonwep/java-express"><img
2724 alt="Build Status"
2825 src="https://travis-ci.org/Simonwep/java-express.svg?branch=master"></a>
29- <a href="https://maven-badges.herokuapp.com/maven-central/com.github.Simonwep/java-express"><img
30- alt="Build Status"
31- src="https://maven-badges.herokuapp.com/maven-central/com.github.Simonwep/java-express/badge.svg"></a>
3226</p >
3327
3428<br >
3529
36- # Getting Started
30+ #### Getting Started
3731``` java
3832Express app = new Express ();
3933
@@ -42,7 +36,39 @@ app.get("/", (req, res) -> {
4236}). listen(); // Will listen on port 80 which is set as default
4337```
4438
45- # Docs:
39+ ## Installation
40+
41+ ### Maven
42+ > Add repository:
43+ ``` xml
44+ <repository >
45+ <id >jitpack.io</id >
46+ <url >https://jitpack.io</url >
47+ </repository >
48+ ```
49+
50+ > Add dependency:
51+ ``` xml
52+ <dependency >
53+ <groupId >com.github.Simonwep</groupId >
54+ <artifactId >java-express</artifactId >
55+ <version >0.1.1</version >
56+ </dependency >
57+ ```
58+
59+ ### Gradle
60+ > Add this to your build.gradle
61+ ``` xml
62+ repositories {
63+ maven { url "https://jitpack.io/" }
64+ }
65+
66+ dependencies {
67+ implementation 'com.github.Simonwep:java-express:0.1.1'
68+ }
69+ ```
70+
71+ ## Docs:
4672* [ Routing] ( #routing )
4773 * [ DynExpress] ( #dynexpress )
4874 * [ Direct] ( #direct )
@@ -62,8 +88,8 @@ app.get("/", (req, res) -> {
6288* [ License] ( #license )
6389* [ Examples] ( #examples )
6490
65- # Routing
66- ## DynExpress
91+ ## Routing
92+ ### DynExpress
6793Express allows the attaching of request-handler to instance methods via the DynExpress annotation:
6894``` java
6995
@@ -109,7 +135,7 @@ public class Bindings {
109135```
110136
111137
112- ## Direct
138+ ### Direct
113139You can add routes (And middlewares) directly to the Express object to handle requests:
114140``` java
115141Express app = new Express ();
@@ -141,7 +167,7 @@ app.on("/user", "CONNECT", (req, res) -> res.send("Connect!"));
141167app. listen();
142168```
143169
144- ## With Router
170+ ### With Router
145171But it's better to split your code, right? With the ` ExpressRouter ` you can create routes and add it later to the ` Express ` object:
146172``` java
147173Express app = new Express () {{
@@ -168,7 +194,7 @@ Express app = new Express() {{
168194}};
169195```
170196
171- # URL Basics
197+ ## URL Basics
172198Over the express object you can create handler for all [ request-methods] ( https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods ) and contexts. Some examples:
173199``` java
174200app. get(" /home" , (req, res) - > {
@@ -180,7 +206,7 @@ app.post("/login", (req, res) -> {
180206});
181207```
182208
183- ## URL Parameter
209+ ### URL Parameter
184210Sometimes you want to create dynamic URL where some parts of the URL's are not static.
185211With the ` : ` operator you can create variables in the URL which will be saved later in a HashMap.
186212
@@ -193,7 +219,7 @@ app.get("/posts/:user/:description", (req, res) -> {
193219});
194220```
195221
196- ### URL Parameter Listener
222+ #### URL Parameter Listener
197223You can also add an event listener when the user called an route which contains an certain parameter.
198224
199225``` java
@@ -209,7 +235,7 @@ app.onParam("id", (req, res) -> {
209235```
210236Now, this function will be called every time when an context is requested which contains the ` id ` parameter placeholder.
211237
212- ## URL Querys
238+ ### URL Querys
213239If you make an request which contains querys, you can access the querys over ` req.getQuery(NAME) ` .
214240
215241Example request: ` GET ` ` /posts?page=12&from=john ` :
@@ -242,7 +268,7 @@ app.get("/showcookie", (req, res) -> {
242268});
243269```
244270
245- ## Form data
271+ ### Form data
246272Over ` req.getFormQuery(NAME) ` you receive the values from the input elements of an HTML-Form.
247273Example HTML-Form:
248274``` html
@@ -266,8 +292,8 @@ app.post("/register", (req, res) -> {
266292});
267293```
268294
269- # HTTP Relevant classes
270- ## Express
295+ ## HTTP Relevant classes
296+ ### Express
271297This class represents the entire HTTP-Server, the available methods are:
272298``` java
273299app. get(String context, HttpRequest handler); // Add an GET request handler
@@ -296,7 +322,7 @@ app.listen(ExpressListener onstart, int port); // Start the asy
296322app. stop(); // Stop the server and all middleware worker
297323```
298324
299- ## Response Object
325+ ### Response Object
300326Over the response object, you have serveral possibility like setting cookies, send an file and more. Below is an short explanation what methods exists:
301327(We assume that ` res ` is the ` Response ` object)
302328
@@ -321,7 +347,7 @@ res.streamFrom(long contentLength, InputStream is, MediaType mediaType) // Send
321347```
322348The response object calls are comments because ** you can only call the .send(xy) once each request!**
323349
324- ## Request Object
350+ ### Request Object
325351Over the ` Request ` Object you have access to serveral request stuff (We assume that ` req ` is the ` Request ` object):
326352
327353``` java
@@ -507,7 +533,7 @@ Send an info message
507533 res. send(" You take use of your session cookie " + count + " times." );
508534});
509535```
510- ## Global Variables
536+ ### Global Variables
511537Java-express also supports to save and read global variables over the Express instance:
512538Example:
513539``` java
@@ -516,7 +542,7 @@ app.get("my-data"); // Returns "Hello World"
516542```
517543
518544## Examples
519- ### Very simple static-website
545+ #### Very simple static-website
520546``` java
521547
522548// Create instance
@@ -527,7 +553,7 @@ new Express() {{
527553}};
528554```
529555
530- ### File download
556+ #### File download
531557``` java
532558
533559// Your file
@@ -540,7 +566,7 @@ new Express() {{
540566 get(" /download-me" , (req, res) - > res. sendAttachment(downloadFile));
541567}};
542568```
543- ### Send cookies
569+ #### Send cookies
544570``` java
545571new Express () {{
546572
@@ -556,5 +582,5 @@ new Express() {{
556582}};
557583```
558584
559- # License
585+ ### License
560586This project is licensed under the MIT License - see the [ LICENSE] ( https://github.com/Simonwep/java-express/blob/master/LICENSE ) file for details.
0 commit comments