Skip to content

Commit

Permalink
Add example-robaho project (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbygrave authored Dec 1, 2024
1 parent d25a6ce commit 04ece11
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 0 deletions.
40 changes: 40 additions & 0 deletions examples/example-robaho/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.avaje</groupId>
<artifactId>examples</artifactId>
<version>0.1</version>
</parent>

<artifactId>example-robaho</artifactId>

<dependencies>
<dependency>
<groupId>io.github.robaho</groupId>
<artifactId>httpserver</artifactId>
<version>1.0.10</version>
</dependency>

<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-jex</artifactId>
<version>3.0-RC4</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk-platform-logging</artifactId>
<version>2.0.16</version>
</dependency>

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.12</version>
</dependency>

</dependencies>
</project>
24 changes: 24 additions & 0 deletions examples/example-robaho/src/main/java/io/avaje/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.avaje;

import io.avaje.jex.Jex;

public class Main {

public static void main(String[] args) {

// Below system property is NOT required as it will register via service loading
// System.setProperty("com.sun.net.httpserver.HttpServerProvider", "robaho.net.httpserver.DefaultHttpServerProvider");

Jex.create()
.routing(routing -> routing
.get("/", ctx -> ctx.text("root"))
.get("/one", ctx -> ctx.text("one"))
.get("/two/{name}", ctx -> {
ctx.text("two Yo " + ctx.pathParam("name"));
})
.post("one", ctx -> ctx.text("posted")))
.port(7002)
.start();

}
}
18 changes: 18 additions & 0 deletions examples/example-robaho/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>TRACE</level>
</filter>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<root level="INFO">
<appender-ref ref="STDOUT"/>
</root>

<logger name="io.avaje.jex" level="TRACE"/>
<logger name="io.avaje.http.client" level="TRACE"/>

</configuration>
1 change: 1 addition & 0 deletions examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<modules>
<module>example-jdk</module>
<module>example-robaho</module>
</modules>

<profiles>
Expand Down

0 comments on commit 04ece11

Please sign in to comment.