Skip to main content
Version: 2.0.0

Embedded Jetty Web Server

QUIPT embeds a lightweight, high-performance Eclipse Jetty 11 HTTP/HTTPS server (QuiptServer) directly within the host process. This eliminates the need for external web servers when serving resource packs, handling external API webhooks, or providing status endpoints.

Server Architecture​

QuiptServer extends org.eclipse.jetty.server.Server and encapsulates route dispatching through QuiptHandler.

graph LR
Client[Incoming HTTP Client / Webhook] --> Connector[Jetty Connector :Port]
Connector --> Server[QuiptServer]
Server --> Handler[QuiptHandler]
Handler --> Route1["/resources/* (ResourcePackHandler)"]
Handler --> Route2["/custom/* (User Servlets)"]

Configuration (quipt.json)​

The embedded server is configured via QuiptConfig.WebData in quipt/data/quipt.json:

quipt/data/quipt.json
{
"webData": {
"protocol": "HTTP",
"host": "0.0.0.0",
"port": 5252
},
"access_token": "secret_token_here"
}

Configuration Fields​

FieldTypeDefaultDescription
protocolStringHTTPProtocol string: HTTP or HTTPS.
hostString127.0.0.1Binding IP address (0.0.0.0 to listen on all network interfaces).
portInteger5252Listening TCP port number.
access_tokenString""Optional master token for authenticated endpoints.

Registering Custom Handlers & Servlets​

Developers can mount custom endpoints onto the server by extending QuiptServlet or jakarta.servlet.http.HttpServlet.

Example: Custom REST Endpoint​

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import live.qsmc.quipt.core.Quipt;
import live.qsmc.quipt.core.server.QuiptServlet;
import java.io.IOException;

public class PingHandler extends QuiptServlet {

public PingHandler() {
super(Quipt.INSTANCE.server());
}

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("application/json");
resp.setStatus(HttpServletResponse.SC_OK);
resp.getWriter().println("{\"status\":\"ok\",\"timestamp\":" + System.currentTimeMillis() + "}");
}
}

Mounting the Route​

PingHandler pingHandler = new PingHandler();

// Mount on "/ping" and all sub-paths
Quipt.INSTANCE.server().handler().handle("ping", pingHandler, "ping/*");

Built-in Endpoints​

RouteHandler ClassDescription
/resourcesResourcePackHandlerServes the generated resource pack pack.zip.
/resources/updateResourcePackHandlerWebhook endpoint invoked by GitHub/GitLab on push events to trigger instant resource pack sync.

Production Deployment & Reverse Proxies​

For public servers, it is recommended to bind host to 127.0.0.1 and place a reverse proxy like Nginx or Caddy in front:

Nginx Example Configuration​

server {
listen 80;
server_name pack.example.com;

location / {
proxy_pass http://127.0.0.1:5252;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}