D web apps: cgi.d now supports scgi

Andrea Fontana nospam at example.com
Sun Mar 25 04:04:22 PDT 2012


+1 for scgi support :)

On Sunday, 25 March 2012 at 04:43:07 UTC, Adam D. Ruppe wrote:
> https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
>
> some docs:
> http://arsdnet.net/web.d/cgi.html
> http://arsdnet.net/web.d/cgi.d.html
>
> The file cgi.d in there is my base library for web apps.
>
> Previously, it spoke regular CGI, FastCGI (with help
> from a C lib) and HTTP (with help from the netman.d
> and httpd.d files in that github).
>
>
> Now, in addition to those options, it also speaks
> SCGI - all by itself - and it can speak http without
> needing helper modules.
>
> The new embedded http server should work on all
> platforms too, not just linux like the old one, but
> I haven't tested it yet.
>
>
> This finishes out all the major web app interfaces
> that I'm aware of.
>
>
> To use them, you write your app with a GenericMain
> and always communicate through the Cgi object it
> passes you.
>
> ===
> import arsd.cgi;
> void hello(Cgi cgi) {
>     cgi.write("Hello, world! " ~ cgi.request("name") ~ "\n");
> }
> mixin GenericMain!hello;
> ===
>
>
> And then compile:
>
> dmd hello.d arsd/cgi.d # builds a CGI binary
> dmd hello.d arsd/cgi.d -version=fastcgi # FastCGI. needs 
> libfcgi C lib
> dmd hello.d arsd/cgi.d -version=scgi # SCGI
> dmd hello.d arsd/cgi.d -version=embedded_httpd # built-in http 
> server
>
>
> The API is the same with all four options.
>
> With cgi or fastcgi, you put the binary where your web
> server can run it.
>
> With scgi and embedded_httpd, you run the binary. It
> persists as an application server. On the command line,
> you can say use the option "--port 5000" for example
> to change the listening tcp port.
>
> The default for httpd right now is 8085. The default
> for scgi is 4000.
>
>
>
> Well, I don't have much else to say, but since it
> now does all four of the big interfaces easily,
> I thought I'd say something here.
>
> If you're interested in web programming with D,
> this will lay the foundation for you.




More information about the Digitalmars-d-announce mailing list