最近需要用到goahead服务器,因此花了一番时间对goahead服务器进行了简单的研究。网上都有对goahead服务器的移植进行讲解的博客,虽然讲的不够细节,但是对于启动服务器也已经是足够了,今天我这边博客主要是讲解一下我对goahead中goaction的理解和使用。如果有时间的话,我再出一个详细全面的goahead服务器的移植博客。
在开始我们的博客之前,首先我们来讲一下什么是goaction。为了让大家有个全面的了解,以下关于goaction的描述均为goahead官方网站英文描述。
官方原文:
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(
在开始我们的博客之前,首先我们来讲一下什么是goaction。为了让大家有个全面的了解,以下关于goaction的描述均为goahead官方网站英文描述。
官方原文:
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(