GoForms™

The GoAhead WebServer implements the standard Common Gateway Interface (CGI) as an in-memory forms processor called GoForms™. Old style CGI processing results in the creation of a new process for every request to a CGI Url. As CGI is often the primary means of implementing user input, this is slow and cumbersome. GoForms is a more suitable solution for embedded systems that demand compact, high performance solutions.

GoForm procedures run in-memory without creating a new process for each browser connection. By sharing the address space with the GoAhead WebServer, GoForms procedures can directly access the full request context. The GoForm handler also automatically decodes and parses all POST and query data for easy access. A convenient API (see websGetVar) permits easy access to CGI variables.

GoForms is implemented as a URL Handler which interprets URLs that begin with "/goform". The URL segment following "goform" defines the form name with query details appended to the URL. For example:

/goform/myForm?name=John&age=30           

This will call the GoForm procedure "myForm" and automatically decode the querystring "name=John&age=30" and define GoForm variables called "name" and "age". In addition to POST and query data, the standard CGI variables are also defined.

GoForm procedures are defined by the websFormDefine API call and conform to the following prototype:

void myForm(webs_t wp, char_t *path, char_t *query)
{
    websHeader(wp);
    websWrite(wp, "Name %s", websGetVar(wp, "name", "")); 
    websWrite(wp,  "Age %s", websGetVar(wp, "age", ""));
    websFooter(wp);
    websDone(wp, 200);
}

The GoForm procedure is responsible for writing the HTTP header and HTML document contents back to the user's browser. websHeader creates a standard HTTP header with initial HTML tags. websFooter closes the document with a closing HTML tag. Inside the GoForm procedure, websGetVar, websRedirect, websWrite, and websWriteBlock are some of the most useful API calls.

See Also

Active Server PagesJavaScript, URL Handlers, websSecurityHandler, websUrlHandlerDefine