Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow an application to supply its own dispatch module for a server by setting the new dispatchmod variable in the server config. The module is expected to export a dispatch/1 function that returns one of the following atoms: * done: this indicates the dispatch module has handled the request and sent the response, and Yaws should go look for a new request on this connection * closed: same as "done" but also indicates the dispatch module has closed the connection * continue: this tells Yaws to continue with the normal dispatch path
- Loading branch information
Showing
10 changed files
with
146 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-module(dispatchmod_tester). | ||
-export([dispatch/1]). | ||
-include("../../include/yaws_api.hrl"). | ||
|
||
dispatch(#arg{clisock=Sock}=A) -> | ||
{abs_path, Path} = (A#arg.req)#http_request.path, | ||
case Path of | ||
"/done" -> | ||
ok = gen_tcp:send(Sock, <<"HTTP/1.1 204 No Content\r\nX-DispatchMod: true\r\n\r\n">>), | ||
done; | ||
"/closed" -> | ||
ok = gen_tcp:send(Sock, <<"HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n">>), | ||
gen_tcp:close(Sock), | ||
closed; | ||
_ -> | ||
continue | ||
end. |