D2 & Web-Framework

Nick Sabalausky a at a.a
Thu Jul 14 14:53:25 PDT 2011


"Adam Ruppe" <destructionator at gmail.com> wrote in message 
news:ivms0h$s8p$1 at digitalmars.com...
>
> Finally, web.d builds on top of dom and cgi to provide a higher
> level interface; instead of manually parsing the cgi object, it tries
> to do it automatically, to call your functions with reflection.
>

I recently started giving your web.d a try, but I'm having trouble figuring 
out how to use the executable. I have this (a modification of your ApiDemo 
example):

import arsd.cgi;
import arsd.web;

class ArticlesApi : ApiProvider
{
    private static Document document;

    private /+static+/ void loadDocument()
    {
        if(!document)
            document = new Document(import("document.html"), true, true);
    }

    this()
    {
        loadDocument();
    }

    override Document _defaultPage()
    {
        auto e = _getGenericContainer();
        e.innerText = "Hello!";

        return document;
    }

    override Element _getGenericContainer()
    {
        return document.getElementById("page-content");
    }
}
mixin FancyMain!ArticlesApi;

But, when I try to run it through IIS, it just does a 302 redirect to 
"localstart.asp". I totally forget how HTTP headers are passed to an exe for 
CGI, but FWIW, if I run it at the command-line, no matter what I give as the 
argument (or no argument) it just gives back:

Status: 302 Found
Location: /
Cache-Control: private, no-cache="set-cookie"
Expires: 0
Pragma: no-cache
Content-Type: text/html; charset=utf-8

I don't know if this is related, but something else I should point out 
anyway: There are a couple places in web.d that call 
"cgi.setResponseLocation()" with two arguments (the second arg is the bool 
"false"). But the only setResponseLocation() in cgi.d just takes the one 
argument, it doesn't have a second argument. So I commented out the ", 
false" arg to make it compile.





More information about the Digitalmars-d mailing list