RejectedSoftware Forums

Sign up

Error with non-GET methods

Hi. Could someone explain why I'm getting 404 error in non GET methods?

module app;
import vibe.d;
    
void showHome(HTTPServerRequest req, HTTPServerResponse res)
{
    res.writeBody(to!string(req.method), "text/plain");  
}
    
shared static this()
{
    auto router = new URLRouter;
    router.get("/", &showHome);
    auto settings = new HTTPServerSettings();
    settings.port = 8080;
    settings.bindAddresses = ["::1", "127.0.0.1"];
    listenHTTP(settings, router);
}

404 - Not Found

Not Found

Internal error information:
vibe.http.common.HTTPStatusException@../../../../../root/.dub/packages/vibe-d-0.7.18/source/vibe/http/server.d(1390): Not Found
----------------
./vibed(void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerListener)+0x12b) [0x614bcb]
./vibed(void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest,             vibe.http.server.HTTPServerResponse)).doListen(vibe.http.server.HTTPServerSettings, vibe.http.server.HTTPServerListener, immutable(char)[]).__lambda4(vibe.core.net.TCPConnection)+0x2c) [0x610ddc]
./vibed(void vibe.core.drivers.libevent2_tcp.onConnect(int, short, void*).ClientTask.execute()+0x2d6) [0x69a356]
./vibed(void vibe.core.core.CoreTask.run()+0xf5) [0x68a4d5]
./vibed(void core.thread.Fiber.run()+0x2a) [0x762596]
./vibed(fiber_entryPoint+0x61) [0x7624a1]
[(nil)]

Using dmd 2.064.2, vibe 0.7.18.

Re: Error with non-GET methods

Because you have only registered GET routes. You may be interested in registering with router.any() instead.

Re: Error with non-GET methods

On Wed, 08 Jan 2014 07:29:13 GMT, Dicebot wrote:

Because you have only registered GET routes. You may be interested in registering with router.any() instead.

Ah, thanks. Hadn't thought about this.