RejectedSoftware Forums

Sign up

REST API Example - HTTPStatusException ... server.d: Not Found

I am brand new to D, and am trying out the REST API demo provided at:

https://github.com/rejectedsoftware/vibe.d/blob/master/examples/rest/source/app.d

The application compiles and runs, but when I attempt to execute a query against the API (as follows)

curl -X GET http://localhost:8080/some_info/

I get the following error:

404 - Not Found

Not Found

Internal error information:
vibe.http.common.HTTPStatusException@../../.dub/packages/vibe-d-master/source/vibe/http/server.d(1271): Not Found
----------------
/tmp/dub/346773797/vibe(void vibe.http.server.handleHTTPConnection(vibe.core.net.TCPConnection, vibe.http.server.HTTPServerListener)+0x143) [0x5d4a0b]
/tmp/dub/346773797/vibe(void vibe.http.server.listenHTTPPlain(vibe.http.server.HTTPServerSettings, void delegate(vibe.http.server.HTTPServerRequest, vibe.http.server.HTTPServerResponse)).void doListen(vibe.http.server.HTTPServerSettings, vibe.http.server.HTTPServerListener, immutable(char)[]).void __lambda54(vibe.core.net.TCPConnection)+0x2c) [0x5d10a4]
/tmp/dub/346773797/vibe(extern (C) nothrow void vibe.core.drivers.libevent2_tcp.onConnect(int, short, void*).void ClientTask.execute()+0x2d6) [0x66bc36]
/tmp/dub/346773797/vibe(void vibe.core.core.CoreTask.run()+0xf2) [0x67056a]
/tmp/dub/346773797/vibe(void core.thread.Fiber.run()+0x2a) [0x6e23b2]
/tmp/dub/346773797/vibe(fiber_entryPoint+0x61) [0x6e22bd]

Based on the code Example1API should provide the /some_info/ API.

Any help is appreciated.

Craig

Re: REST API Example - HTTPStatusException ... server.d: Not Found

On Wed, 14 Aug 2013 21:13:42 GMT, Craig Dillabaugh wrote:

I am brand new to D, and am trying out the REST API demo provided at:

https://github.com/rejectedsoftware/vibe.d/blob/master/examples/rest/source/app.d

The application compiles and runs, but when I attempt to execute a query against the API (as follows)

curl -X GET http://localhost:8080/some_info/

I get the following error:

(...)

The Example1API class uses the new @rootPathFromName attribute, which adds a prefix for the API based on its name. In this case that would be "/example1api/" and the complete URL should be (untested) "http://localhost:8080/example1api/some_info/".

You can also run the application with --vv (i.e. "dub -- -vv") to get a list of all registered routes printed - plus a lot of other, less useful, stuff.

Re: REST API Example - HTTPStatusException ... server.d: Not Found

On Wed, 14 Aug 2013 22:13:11 GMT, Sönke Ludwig wrote:

On Wed, 14 Aug 2013 21:13:42 GMT, Craig Dillabaugh wrote:

I am brand new to D, and am trying out the REST API demo provided at:

https://github.com/rejectedsoftware/vibe.d/blob/master/examples/rest/source/app.d

The application compiles and runs, but when I attempt to execute a query against the API (as follows)

curl -X GET http://localhost:8080/some_info/

I get the following error:

(...)

The Example1API class uses the new @rootPathFromName attribute, which adds a prefix for the API based on its name. In this case that would be "/example1api/" and the complete URL should be (untested) "http://localhost:8080/example1api/some_info/".

You can also run the application with --vv (i.e. "dub -- -vv") to get a list of all registered routes printed - plus a lot of other, less useful, stuff.

This works. Thanks very much.

Craig

Re: REST API Example - HTTPStatusException ... server.d: Not Found

On Thu, 15 Aug 2013 14:20:40 GMT, Craig Dillabaugh wrote:

On Wed, 14 Aug 2013 22:13:11 GMT, Sönke Ludwig wrote:

On Wed, 14 Aug 2013 21:13:42 GMT, Craig Dillabaugh wrote:

I am brand new to D, and am trying out the REST API demo provided at:

https://github.com/rejectedsoftware/vibe.d/blob/master/examples/rest/source/app.d

The application compiles and runs, but when I attempt to execute a query against the API (as follows)

curl -X GET http://localhost:8080/some_info/

I get the following error:

(...)

The Example1API class uses the new @rootPathFromName attribute, which adds a prefix for the API based on its name. In this case that would be "/example1api/" and the complete URL should be (untested) "http://localhost:8080/example1api/some_info/".

You can also run the application with --vv (i.e. "dub -- -vv") to get a list of all registered routes printed - plus a lot of other, less useful, stuff.

This works. Thanks very much.

Craig

A comment about the API and this forum for anyone who may be viewing this through the web forum.

The path above should read "/example1_api/" (notice the underscore). It seems like the web forum strips out the underscore in the path name (although I see it when replying, since all the fancy formatting is omitted.)

Also, the "dub -- -vv" option was great. Would it be OK if I edited the example on GitHub to comment on runnign dub with this option, and on the impact of @rootPathFromName.

Craig

Re: REST API Example - HTTPStatusException ... server.d: Not Found

On Thu, 15 Aug 2013 14:53:05 GMT, Craig Dillabaugh wrote:

On Thu, 15 Aug 2013 14:20:40 GMT, Craig Dillabaugh wrote:

On Wed, 14 Aug 2013 22:13:11 GMT, Sönke Ludwig wrote:

The Example1API class uses the new @rootPathFromName attribute, which adds a prefix for the API based on its name. In this case that would be "/example1api/" and the complete URL should be (untested) "http://localhost:8080/example1api/some_info/".

You can also run the application with --vv (i.e. "dub -- -vv") to get a list of all registered routes printed - plus a lot of other, less useful, stuff.

This works. Thanks very much.

Craig

A comment about the API and this forum for anyone who may be viewing this through the web forum.

The path above should read "/example1_api/" (notice the underscore). It seems like the web forum strips out the underscore in the path name (although I see it when replying, since all the fancy formatting is omitted.)

Good catch! This is a "feature" of Markdown, probably the best way to write it is in single back-ticks: "/examples1_api/".

Also, the "dub -- -vv" option was great. Would it be OK if I edited the example on GitHub to comment on runnign dub with this option, and on the impact of @rootPathFromName.

Sounds like a good idea. I'll change the route list to use logDiagnostic so that "dub -- -v" is sufficient and all that other debug output disappears.