goahead之GoAction实现

本文主要介绍了Goahead服务器中的GoActions,一种用于创建动态网页的高效技术,避免了传统CGI的低效问题。GoActions是直接绑定到特定URI的C语言函数,能够直接响应客户端请求,无需为每个请求创建新进程。文章通过官方描述和示例解释了GoActions的工作原理和定义方法,并提及了使用makeme工具进行项目构建的相关内容。
摘要由CSDN通过智能技术生成
最近需要用到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(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值