digitalmars.D.learn - vib.d suppress 404 for no content written
- Nicholas Wilson (13/13) Feb 14 2018 I have an endpoint that is a post:
- Seb (4/17) Feb 14 2018 You mean `writeVoidBody`
- Nicholas Wilson (2/24) Feb 14 2018 Thanks!
- aberba (2/24) Feb 14 2018 Seb, are you the one doing the vibe.d demo collections?
- Seb (35/36) Feb 14 2018 Do you mean this?
I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do not write anything to res (deliberately) but want to set the status code. However it returns 404, because no content is written. How can I make it return 200? FWIW its a member of a web interface class. Thanks Nic
Feb 14 2018
On Wednesday, 14 February 2018 at 14:30:19 UTC, Nicholas Wilson wrote:I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do not write anything to res (deliberately) but want to set the status code. However it returns 404, because no content is written. How can I make it return 200? FWIW its a member of a web interface class. Thanks NicYou mean `writeVoidBody` See Also: https://github.com/vibe-d/vibe.d/issues/2065
Feb 14 2018
On Wednesday, 14 February 2018 at 14:58:14 UTC, Seb wrote:On Wednesday, 14 February 2018 at 14:30:19 UTC, Nicholas Wilson wrote:Thanks!I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do not write anything to res (deliberately) but want to set the status code. However it returns 404, because no content is written. How can I make it return 200? FWIW its a member of a web interface class. Thanks NicYou mean `writeVoidBody` See Also: https://github.com/vibe-d/vibe.d/issues/2065
Feb 14 2018
On Wednesday, 14 February 2018 at 14:58:14 UTC, Seb wrote:On Wednesday, 14 February 2018 at 14:30:19 UTC, Nicholas Wilson wrote:Seb, are you the one doing the vibe.d demo collections?I have an endpoint that is a post: void postStuff(HTTPServerRequest req, HTTPServerResponse res) { // do some stuff with req res.statusCode = 200; } I do not write anything to res (deliberately) but want to set the status code. However it returns 404, because no content is written. How can I make it return 200? FWIW its a member of a web interface class. Thanks NicYou mean `writeVoidBody` See Also: https://github.com/vibe-d/vibe.d/issues/2065
Feb 14 2018
On Wednesday, 14 February 2018 at 21:16:23 UTC, aberba wrote:Seb, are you the one doing the vibe.d demo collections?Do you mean this? https://github.com/wilzbach/vibe-d-by-example Yes, that's me, but it still needs a lot of work and I haven't got around polishing it for an alpha "release", but the examples there should be fully functional with ~>vibe.d-0.8.3-alpha.1 BTW I also have a fork of vibe.web.web at https://github.com/teamhackback/hb-web which adds all the convenience features that I haven't been able to get upstream so far [1]. A short overview of what I miss in vibe.web.web: --- class Service { // Returning strings (instead of res.writeBody) string getString() { return "string"; } // https://github.com/vibe-d/vibe.d/pull/1854 // Access to Json auto postJson(Json _json) { return _json; } // https://github.com/vibe-d/vibe.d/pull/1853 // Automatically serialize data types auto postStruct(MyStruct st) { return st.foo + 3; } // https://github.com/vibe-d/vibe.d/pull/1697 // https://github.com/vibe-d/vibe.d/pull/1698 // path is automatically set to /user/:id // works for all _-prefixed variables that don't have any inference yet (i.e. _error still works) void getUser(string _id, HTTPServerResponse res) { res.writeBody("User: " ~ _id); } } --- Though to be fair, things improved a bit in Vibe.d 0.8.2 and `request` and `response` are now available. They refer to current request. [1] https://github.com/vibe-d/vibe.d/pulls/wilzbach
Feb 14 2018