More vibe.d : Receiving Post params
    seany 
    seany at uni-bonn.de
       
    Sun Feb  2 00:55:05 UTC 2020
    
    
  
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
    
    
More information about the Digitalmars-d-learn
mailing list