最近需要用到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(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.
小编自翻:
Goactions
传统的通关网关接口(也就是CGI)是一个效率低的为了创造出动态交互网页页面的技术,为什么这么说呢?因为CGI为每个请求创造一个新的进程来处理并生成结果。这样的生成动态网页的方式显的效率低下而且繁琐笨重。goahead提供了一个更高效的方式来代替CGI。它被称之为“goactions”,对嵌入式系统来说,这是一个更加合适,严谨,积极有效的方法。

goactions是直接和具体的URL联系在一起的C语言函数。它不需要为每一次的请求创建一个新的进程,通过和goahead分享地址空间,goactions直接访问整个需求,goaction通过行为处理来支持。

Goaction定义
goactions就是websDefineAction API。我们需要先创建一个goaction的函数,在函数体中调用API来生成新的动态页面。最后需要在main函数中注册一个这个函数,调用APIwebsDefineAction进行注册。然后编译就可以了。关于建议方式,官方提供了三种,分别是IDE、Make和makeme命令。

今天我跟各位道友分享一下我对makeme的理解。
首先你需要下载makeme。你可以从 Embedthis MakeMe Download这个网站进行下载和安装。
如何进行安装呢?下面我针对linux系统进行讲解。如果大家想在不同的平台上进行安装,可以去下面的网址看更加详细、更加原版的安装讲解。
网址为https://embedthis.com/makeme/doc/start/installing.html。有需要的同学可以自己去看看,毕竟想成为一个合格的程序员,对英文文档的阅读能力是最基础的。
makeme是一个可获得的代码资源分布,它需要以下环境的支持。
linux - GNU C/C++需要2.6以上的版本
windows - WIN7系统装有VS2010及以上的版本
MAC OS X - 10.8及以上

代码的获取方式有两种,一种是去官方网站下载,另外一种是去GitHub等托管平台下载。请记住下载稳定的版本。请记住下载稳定的版本。请记住下载稳定的版本。重要的事情说三遍。
安装命令为:
tar xfz makeme-0.10.5-0-src.tgz
make boot
sudo make install
你可以简单地调用makeme通过me
$ me
me.es: ERROR: Can't find suitable start.me.
Run "me --gen start" to create stub start.me
这表明你准备好开始创建你的第一个start.me文件。

另外,你可以显示不同的makeme命令选项,如下所示:
$ me help
Usage: me [options] [targets|actions] ...
Options:
--benchmark                              # Measure elapsed time
--chdir dir                              # Directory to build from
--configure /path/to/source              # Configure for building
--continue                               # Continue on errors
--debug                                  # Same as --profile debug
--depth level                            # Set utest depth level
--diagnose                               # Emit diagnostic trace
--dump                                   # Dump the full project me file
--endian [big|little]                    # Define the CPU endianness
--file file.me                           # Use the specified me file
--force                                  # Override warnings
--gen [make|nmake|sh|vs|xcode|main|start]# Generate project file
--help                                   # Print help message
--import                                 # Import standard me environment
--keep                                   # Keep intermediate files
--log logSpec                            # Save errors to a log file
--nocross                                # Build natively
--overwrite                              # Overwrite existing files
--out path                               # Save output to a file
--platform os-arch-profile               # Build for specified platform
--pre                                    # Pre-process a source file to stdout
--prefix dir=path                        # Define installation path prefixes
--profile [debug|release|...]            # Use the build profile
--quiet                                  # Quiet operation. Suppress trace
--rebuild                                # Rebuild all specified targets
--reconfigure                            # Reconfigure with existing settings
--release                                # Same as --profile release
--rom                                    # Build for ROM without a file system
--set [feature=value]                    # Enable and a feature
--show                                   # Show commands executed
--static                                 # Make static libraries
--unicode                                # Set char size to wide (unicode)
--unset feature                          # Unset a feature
--version                                # Display the me version
--verbose                                # Trace operations
--watch [sleep time]                     # Watch for changes and rebuild
--why                                    # Why a target was or was not built
--with PACK[=PATH]                       # Build with package at PATH
--without PACK                           # Build without a package

如果你想了解更多关于makeme,你可以打开链接https://embedthis.com/makeme/doc/start/installing.html进行查看。

如果有什么不对的地方欢迎大家指针。

同样也希望,如果你有什么不一样的见解,非常乐意大家加我的微信一起分享知识。

下一篇我再抽时间写个具体的实际例程。

goahead之GoAction实现相关推荐

  1. Goahead嵌入式linux移植资料整理

    环境 官方文档:https://www.embedthis.com/goahead/doc/ 源码下载: goahead-4.1.0-src.tgz 系统平台:Ubuntu 12.04.4 gcc v ...

  2. 嵌入式web框架 goahead 搭建

    概述 GoAhead WebServer 是世界上最受欢迎的嵌入式Web 服务器.它简单,小巧,是高效托管嵌入式web应用程序的理想选择. GoAhead 经过优化,可通过事件驱动的的单线程内核托管动 ...

  3. web server大全之GoAhead移植(转载)

    转自:http://linux.chinaunix.net/techdoc/develop/2009/06/19/1119124.shtml 注:最近在做goAhead web server和移植其到 ...

  4. Web开发之Goahead

    在说GoAhead之前先说下一下web. Web Server中文名称叫网页服务器或web服务器.WEB服务器也称为WWW(WORLD WIDE WEB)服务器,主要功能是提供网上信息浏览服务. We ...

  5. goahead content-length为0时的问题

    gohead问题描述 UI将获取扫描无线列表的接口formWifiApScan,由get换成了POST,此时无法获取到数据,通过抓包分析,为webserver未正常及时返回数据,同时看到content ...

  6. GoAhead 2.5 Web Server 网页ROM化的改进

    GoAhead 2.5 网页ROM化的改进 GoAhead 是嵌入式Web Server设计的首选利器,其中将HTML文件及其资源转换为*.c文件编译进最终执行文件的功能,为一些没有文件系统的嵌入式工 ...

  7. goahead php,Goahead移植教程 | 学步园

    之前在系统中用的是boa webserver ,但是在频繁提交多次后,boa会出现request.c 99错误并刷屏,造成系统无法正常工作,于是采用了goahead webserver,这个也是适用于 ...

  8. goahead上传文件【原创】

    以前针对goahead研究过如何使用cookie,如今在使用它进行上传文件时又出现了一点问题,首先,之前goahead在原来的板子跑的时候,上传文件一直正常,使用的mips交叉编译.现在使用arm交叉 ...

  9. goahead 的认证和自定义登陆页面的cookie使用【原创】

    Author:张继飞 goahead认证,允许下面几种方式. NONE - the URL page cannot be accessed.  FULL - the URL can always be ...

最新文章

  1. Cell Stem Cell:研究人员开发出大脑类器官用于研究认知障碍!
  2. binaryreader java,C# 二进制文件的读写 | 菜鸟教程
  3. 解决Navicat 出错:1130-host . is not allowed to connect to this MySql server,MySQL
  4. 刘歧:FFmpeg Filter深度应用
  5. spark读取csv转化为rdd(python+scala+java三种代码汇总)
  6. SendMessage函数的常用消息及其应用
  7. SpringBoot2 整合OAuth2组件,模拟第三方授权访问
  8. 蔡高厅老师 - 高等数学阅读笔记 - 16 定积分的应用(旋转积、平面曲线的弧长、阿基米德螺旋、旋转体的侧面积、定积分物理应用-变力做功) -(71、72、73)
  9. 计算机根服务器 信息安全,信息安全课件
  10. 1.1.0-简介-P11-分布式锁的解决方案
  11. [转]ie6下CSS存在的BUG
  12. Java Web架构演变
  13. latex论文模板双栏
  14. jdk1.6-64下载
  15. Windows下的发包工具推荐[Colasoft Packet Builder]含使用教程
  16. The name `AssetDatabase' does not exist in the current context
  17. 像冯满天老师一样热爱一样东西
  18. 『深度应用』NLP机器翻译深度学习实战课程·零(基础概念)
  19. 微信小程序 php解密,微信小程序des加密、PHP des解密
  20. 音乐艺考生的视唱练耳小技巧

热门文章

  1. MFC之图像绘制---高速绘图控件(High-speed Charting Control)应用(一)
  2. C语言 static 声明静态变量?大佬原来用它干这事!
  3. 16个tomcat面试题
  4. sqlserver java驱动_sqlserver jdbc驱动
  5. wifi 小程序 透传_微信小程序之一键连接wifi
  6. pyecharts主题theme风格推荐
  7. getOutputStream() has already been called for this response 当前响应已经调用了方法getOutputStream()
  8. HDU5761 Rower Bo
  9. 使用WordPress搭建个人网站
  10. SqlServer 触发器 详细讲解