www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - More vibe.d : Receiving Post params

reply seany <seany uni-bonn.de> writes:
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
parent Steven Schveighoffer <schveiguy gmail.com> writes:
On 2/1/20 7:55 PM, seany wrote:

 How do I intercept POST params? Thank you
Look 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