Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjdev/apache-mod-v8
mod_v8 is Javascript V8 Engine handler module for Apache HTTPD Server.
https://github.com/kjdev/apache-mod-v8
Last synced: 25 days ago
JSON representation
mod_v8 is Javascript V8 Engine handler module for Apache HTTPD Server.
- Host: GitHub
- URL: https://github.com/kjdev/apache-mod-v8
- Owner: kjdev
- License: apache-2.0
- Created: 2012-05-02T02:32:00.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-05-14T06:41:46.000Z (over 12 years ago)
- Last Synced: 2024-11-18T00:52:39.395Z (about 2 months ago)
- Language: C++
- Size: 134 KB
- Stars: 3
- Watchers: 8
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mod_v8 #
mod_v8 is Javascript V8 Engine handler module for Apache HTTPD Server.
## Dependencies ##
* [V8](http://code.google.com/p/v8)
* [libapreq2](http://httpd.apache.org/apreq)## Build ##
% ./autogen.sh (or autoreconf -i)
% ./configure [OPTION]
% make
% make install### Build Options ###
V8 path.
* --with-v8=PATH [default=/usr/include]
* --with-v8-lib=PATH [default=no]V8 isolate.
* --enable-v8-isolate [default=no]
apache path.
* --with-apxs=PATH [default=yes]
* --with-apr=PATH [default=yes]
* --with-apreq2=PATH [default=yes]## Configration ##
httpd.conf:
LoadModule v8_module modules/mod_v8.so
AddHandler v8-script .v8## Example ##
test.v8:
//apache log (critical error log): ap.log(#val#)
ap.log("hello");//output: ap.rputs(#val#)
ap.rputs("Hello, World" + "\n");//request parameter (method/uri/filename): ap.request(#val#)
ap.rputs("Method = " + ap.request("method") + "\n");
ap.rputs("Uri = " + ap.request("uri") + "\n");
ap.rputs("Filename = " + ap.request("filename") + "\n");
ap.rputs("Remote IP = " + ap.request("remote_ip") + "\n");//request header: ap.header(#val#)
ap.rputs("Header: Host = " + ap.header("Host") + "\n");
ap.rputs("Header: User-Agent = " + ap.header("User-Agent") + "\n");//request header keys: ap.header()
var headers = ap.header();
for (var i = 0; i < headers.length; i ++) {
ap.rputs(headers[i] + " => " + ap.header(headers[i]) + "\n");
}//request params: ap.params(#val#)
ap.rputs("Params: test = " + ap.params("test") + "\n");//dirname: ap.dirname(#val#)
ap.rputs(ap.dirname(ap.request.filename) + "\n");//include: ap.include(#val#)
ap.include(ap.dirname(ap.include.filename) + "/sub.v8");//json: ap.toJson(#val#)
var obj = { test: "TEST", hoge:"HOGE" };
ap.rputs(ap.toJson(obj) + "\n");//content-type: ap.content_type(#val#)
//default: text/plain; charset=UTF-8
ap.content_type("text/html; charset=UTF-8");//Reponse header: Location
ap.rheader("Location", "hoge.html");
ap.rcode(302);//Cookie: read
cookie = ap.header("Cookie");
ap.rputs(cookie + "\n");//Cookie: write
ap.rheader("Set-Cookie", "hoge=1");