⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 websurlhandlerdefine.htm

📁 GOAHEAD WEBSERVER嵌入式的源码
💻 HTM
字号:
<html>
<head>
<!- Copyright (c) Go Ahead Software Inc., 1995-2000. All Rights Reserved. ->
<title>websUrlHandlerDefine -- GoAhead WebServer API</title>
<link rel="stylesheet" href="../../../style/doc.css" type="text/css">
</head>

<body>
<table width="550"> <tr><td>
<TABLE border=0 width=100% cellspacing=0 cellpadding=0 CLASS="apiTitle"> <TR> 
<td class="titleLeft" align=left width="33%"><b>websUrlHandlerDefine</b></TD><td class="titleCenter" align=center width="33%"><b> 
GoAhead WebServer API</b></TD><td class="titleRight" align=right width="33%"><B> 
GoAhead EMF</B></TD></TR> </TABLE><HR> <h2>Synopsis</h2><p> Define a new URL handler.</p><h2>Prototype</h2><pre> #include &quot;webs.h&quot; 

 int <b>websUrlHandlerDefine</b>(char_t *path, int (*fn)(webs_t wp, 
    char_t *url, char_t *path, char_t *query), int flags); </pre><h2>Parameters</h2><TABLE WIDTH=100% BORDER="0" CELLPADDING="0" CELLSPACING="0"> 
<TR> <TD VALIGN="TOP" WIDTH="6%">wp <TD WIDTH="94%">Web server connection handle. 
<TR> <TD VALIGN="TOP" WIDTH="6%">url <TD WIDTH="94%">Request URL. <TR> <TD VALIGN="TOP" WIDTH="6%">path 
<TD WIDTH="94%">Request path portion of the URL. <TR> <TD VALIGN="TOP" WIDTH="6%">query 
<TD WIDTH="94%">Query string portion of the URL.</TD></TR> <TR> <TD VALIGN="TOP" WIDTH="6%">flags 
<TD WIDTH="94%">Specify a sorting value to modify the calling order of the handler.</TD></TR> 
</TABLE><h2>Description</h2><P> The websUrlHandlerDefine procedure adds a new 
URL handler by associating a URL path segment with a processing function. URL 
handlers are called in sorted order beginning with the handlers with longer path 
segments. For example, the handler for &quot;/myUrl&quot; would be called before 
the handler for &quot;/my&quot;.</P><P> The flags parameter can specify two special 
sorting values:</P><ul><li>WEBS_HANDLER_FIRST<li>WEBS_HANDLER_LAST</li></ul><P> 
If specified, the flags modify the calling order of the handler. Multiple handlers 
may specify these flags, in which case the order of all the handlers specifying 
WEBS_HANDLER_FIRST is undefined. This is the same for multiple handlers using 
WEBS_HANDLER_LAST.</P><p>A URL handler is a C procedure according to the following 
prototype:</p><pre> int myHandler(webs_t wp, char_t *url, char_t *path, char_t *query); </pre><P>The <i>url</i> parameter contains the entire URL. The <i> path</i> 
parameter holds the URL portion after the hostname and port number. The <i>query</i> 
parameter holds any optional query.</P><p>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 handler may modify the URL request using 
any of the websSetRequest APIs. In this case, if it returns 0, a subsequent URL 
handler will process the modified request.</p><h2>Return Value</h2><p> Returns 
0 if successful, otherwise it returns -1.</p><h2>Example</h2><pre> int myHandler(webs_t 
     wp, char_t *url, char_t *path, char_t *query)
     { /* * Processing here */ return 1; } 
     websUrlHandlerDefine(&quot;&quot;, myHandler, 
     WEBS_HANDLER_FIRST); websUrlHandlerDefine
     (&quot;/mypath&quot;, myOtherHandler, 0); </pre><h2>Stability Classification</h2><p>Stable.</p><h2>See 
Also</h2><p> <A href="websSecurityHandler.htm">websSecurityHandler</A> </p></td></tr></table>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -