blob: f9ecc12e4dda55da6cc1e9b572aa1c3d9a8494ab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import brpaste.web;
import vibe.d;
shared static this() {
// HTTP settings
auto settings = new HTTPServerSettings;
settings.port = 8080;
settings.bindAddresses = [];
readOption("bind|b", &settings.bindAddresses, "Sets the addresses to bind to [127.0.0.1 ::1]");
readOption("port|p", &settings.port, "Sets the port to listen on [8080]");
if(settings.bindAddresses.empty) settings.bindAddresses = [ "127.0.0.1", "::1" ];
// setup router
auto router = new URLRouter;
router.match(HTTPMethod.REPORT, "/health", &health);
router.get("/health", &health);
router.get("/", staticTemplate!"index.dt");
router.post("/", &post);
router.get("/:id", &id);
router.get("/raw/:id", &rawId);
listenHTTP(settings, router);
}
|