现在的位置: 首页 > 综合 > 正文

GoAhead WebServer URL Handlers

2013年01月28日 ⁄ 综合 ⁄ 共 2705字 ⁄ 字号 评论关闭

GoAhead WebServer URL Handlers

The GoAhead WebServer implements a flexible URL handler where the semantics of a URL may be interpreted at run time by multiple URL handlers. URL handlers are given the URL and the option of accepting it for processing. If a handler accepts the URL, no further URL handlers will be called.

 GoAhead WebServer可以实现一个灵活的URL处理程序。一个URL的语义可以在运行的时候被多个URL处理程序解释。URL接受RUL和接受处理选项。如果一个处理程序接受一个URL,就不再会有URL处理程序被调用。

A URL handler specifies a path prefix, a processing function and an order option. The path prefix nominates the URLs of interest. Any URL that matches this URL prefix is given to the handler for processing. A match is deemed to occur if the URL exactly matches the prefix for the length of the prefix. If more than one handler matches, the longest matching URL handler will be called first and so-on in decreasing length order. For example, the following all match the prefix "/my":

/myCar?model=ford

/myPath/model/ford

/my/car/model/ford

A URL处理程序制定一个路径前缀,处理函数和一个命令选项。任何和这个URL路径前缀匹配的的URL都会被提供一个处理程序。如果URL精确的匹配到了前缀的长度,那么就认为一个匹配发生了。如果有多个处理器匹配到了,最长的那个处理器将被优先调用,一次按照长度递减的顺序进行。例如下面都匹配到了前缀"/my"

/myCar?model=ford

/myPath/model/ford

/my/car/model/ford

A URL handler may supply the empty URL prefix, "", and thus match all URLs. The order option enables a URL handler to specify that it wishes to be processed first or last regardless of the URL match. This is specified by the flagsparameter to the websUrlHandlerDefine API call. If multiple handlers may specify these flags, the order of evaluation for the handlers specifiying the same flag is undefined.

A URL handler is a C procedure according to the following prototype:

int myHandler(webs_t wp, char_t *url, char_t *path,

     char_t *query);

一个URL处理程序可以提供一个空的URL前缀,"",以此来匹配所有URLs。顺序选项允许URL处理程序在不关注URL是否匹配的情况下,指定它希望处理的顺序。它是通过websUrlHandlerDefine API中的flagsparameter 来指定的。如果多个处理程序同时指定这些标志的话,对于处理器指定的相同的标志的评估顺序将是不确定的。

根据下面的原型,一个URL处理程序就是一个C处理过程

The url parameter contains the entire URL. The path parameter holds the URL portion after the hostname and port number. The query parameter holds any optional query. The URL handler must return 1 if it elects to process the URL. Otherwise, it should return 0 to indicate that a later URL handler should process the URL.

A URL handler may modify the settings of a request but delay handling of the URL to another handler. The security handler is one example of this. Request settings, form variables, and URL details may be modified by a handler to affect the processing by other handlers.

一个URL参数包换一个完整的URL。路径参数包括URL部分,URL部分在主机名和端口号后面。查询参数包含任何可选的查询。如果URL处理器选择区处理URL必须返回1。否则它会返回0以指示随后的URL处理器应该处理该URL

一个URL处理器也许会修改请求的设置项但是会延迟对另外一个处理程序对URL的处理。安全处理器就是其中的一个典型的例子。请求设置,表格变量,URL细节也许会被一个处理器修改以影响其他处理的处理过程.

抱歉!评论已关闭.