Embedthis GoAhead 3.3.1
Home > Users Guide > GoActions

# Quick Nav

# See Also

# GoActions

The traditional Common Gateway Interface (CGI) is a slow technique for creating dynamic web pages because CGI processing results in the creation of a new process for every request. This is slow and cumbersome. GoAhead provides a high-performance replacement called GoActions™ that is a more suitable solution for embedded systems that demand compact and efficient solutions.

GoActions are "C" language functions that are directly bound to specific URIs. They respond to client requests without creating a new process for each request. By sharing the address space with GoAhead, GoActions can directly access the full request context. GoActions are serviced by the action handler.

## Defining GoActions

GoActions are defined by the websDefineAction API. For example:

    static void buy(Webs *wp)
    {
        websSetStatus(wp, 200);
        websWriteHeaders(wp, 0, 0);
        websWriteEndHeaders(wp);
        websWrite(wp, "Name %s", websGetVar(wp, "name", ""));
        websWrite(wp,  "Age %s", websGetVar(wp, "age", ""));
        websDone(wp);
    }
    websDefineAction("buy", buy);

## Calling GoActions

GoActions are bound to URIs that begin with /action/. When a client requests a URI /action/NAME, the action handler is invoked which then looks for a GoAction by NAME. The function bound to NAME is then is invoked to service the request. For example:

    /action/buy?name=John&item=candy

This will invoke the GoAction buy which will run the bound C function. The action handler will automatically decode the query string "name=John&age=30" and define GoAhead variables called "name" and "age".

The GoAction is responsible for writing the HTTP header and HTML document content back to the user's browser.

© Embedthis Software LLC, 2003-2014. All rights reserved. Embedthis and Embedthis GoAhead are trademarks of Embedthis Software LLC.