digitalmars.D.learn - More vibe.d : Receiving Post params
- seany (25/25) Feb 01 2020 Consider this :
- Steven Schveighoffer (4/5) Feb 01 2020 Look at req.form for POST parameters. They are not unified with queryStr...
Consider this : import vibe.vibe; import std.conv; ushort port = 5502; void main(char[][] args) { auto router = new URLRouter; router.post("/archive", &savedata); router.get("/archive", &savedata); auto settings = new HTTPServerSettings; settings.port = port; settings.bindAddresses = ["::1", "0.0.0.0"]; listenHTTP(settings, router); runApplication(); } void savedata(HTTPServerRequest req, HTTPServerResponse res) { res.writeBody("srver received : " ~ req.queryString); // also tested with to!string(req.params) } Now, I will send POST values like "line=abcdefgh..." to the port under "/archive". I test it under linux :curl -X POST -d "line=000" http://my.secret.site:5502/archive The response is : srver received : How do I intercept POST params? Thank you
Feb 01 2020
On 2/1/20 7:55 PM, seany wrote:How do I intercept POST params? Thank youLook at req.form for POST parameters. They are not unified with queryString. https://vibed.org/api/vibe.http.server/HTTPServerRequest.form -Steve
Feb 01 2020