-
Notifications
You must be signed in to change notification settings - Fork 277
Open
Description
/+ dub.json: {
"name": "test-rest",
"dependencies": {
"vibe-d": "~>0.10"
}
}
+/
module server;
import vibe.core.core;
import vibe.core.log;
import vibe.http.client;
import vibe.http.router;
import vibe.http.server;
import vibe.web.rest;
import std.stdio;
interface API {
void postKeepalive () @safe;
}
class Server : API {
override void postKeepalive () @safe {
logInfo("Ping!");
}
}
int main () {
scope serv = new Server();
auto router = new URLRouter();
router.registerRestInterface(serv);
runTask(() @safe nothrow {
scope (failure) assert(0);
requestHTTP("http://127.0.0.1:4242/keepalive",
(scope req) {
req.method = HTTPMethod.POST;
},
(scope res) {
logInfo("Response status: %s", res.statusCode);
logInfo("Response headers: %s", res.headers);
});
});
listenHTTP("127.0.0.1:4242", router);
return runEventLoop();
} % dub --single server.d
[...]
Running test-rest
Listening for requests on http://127.0.0.1:4242/
Ping!
Response status: 200
Response headers: ["Server": "vibe.d/2.13.0", "Date": "Sun, 31 Aug 2025 15:44:41 GMT", "Keep-Alive": "timeout=10", "Content-Type": "application/octet-stream", "Content-Length": "0"]
I would expect Vibe.d to return a 204 when the return type of a POST method is void.
Metadata
Metadata
Assignees
Labels
No labels