Installation
Spider Silk requires Java 21 or later.
Releases are published to Maven Central, so a build needs no repository beyond the default one.
The current version is 1.1.0.
CHANGELOG.md lists what changed in each release.
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation 'net.benelog.spidersilk:spider-silk-core:1.1.0'
testImplementation 'net.benelog.spidersilk:spider-silk-test:1.1.0'
}
Maven
Maven resolves from Central by default, so pom.xml declares the dependencies and nothing else:
<dependencies>
<dependency>
<groupId>net.benelog.spidersilk</groupId>
<artifactId>spider-silk-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>net.benelog.spidersilk</groupId>
<artifactId>spider-silk-test</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Hello, world
import net.benelog.spidersilk.App;
import net.benelog.spidersilk.WebResponse;
public class Main {
public static void main(String[] args) {
App app = new App();
app.get("/hello/{name}", req -> WebResponse.text("Hello, " + req.pathParam("name")));
app.start(8080);
}
}
$ curl localhost:8080/hello/silk
Hello, silk
spider-silk-core brings embedded Jetty with it, so nothing else is needed to serve a request.
Add spider-silk-tomcat or spider-silk-undertow to run the same app on an embedded Tomcat or Undertow; see Choosing a server.
See Deployment to deploy on an external servlet container instead.
Templates render with jte out of the box.
FreeMarker, Handlebars, and Thymeleaf are modules of their own, added the same way.
spider-silk-jetty-websocket adds WebSocket endpoints, and works on Jetty only.
spider-silk-openapi turns the route list into an OpenAPI document.
Coordinates, packages, and module names
net.benelog.spidersilk is one string, used three ways on purpose.
| Where | What it is |
|---|---|
Group id |
|
Package root |
|
|
The package root the jar carries, so |
The Gradle plugin is applied by that same id, net.benelog.spidersilk, and the Maven parent is net.benelog.spidersilk:spider-silk-maven-parent.
Decision 32 gives the reasoning.