Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nginx-modules/ngx_http_handlersocket_json_module
the nginx module for direct access to MySQL data (by HandlerSocket) and pass data in JSON format
https://github.com/nginx-modules/ngx_http_handlersocket_json_module
handlersocket json module mysql nginx
Last synced: 29 days ago
JSON representation
the nginx module for direct access to MySQL data (by HandlerSocket) and pass data in JSON format
- Host: GitHub
- URL: https://github.com/nginx-modules/ngx_http_handlersocket_json_module
- Owner: nginx-modules
- Created: 2014-04-11T00:10:13.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2011-04-15T07:55:12.000Z (over 13 years ago)
- Last Synced: 2023-06-29T03:11:03.694Z (over 1 year ago)
- Topics: handlersocket, json, module, mysql, nginx
- Language: C
- Homepage:
- Size: 199 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
### Introduction
NGX_HTTP_HANDLERSOCKET_JSON_MODULE is an [nginx] (http://nginx.org/) module to get full use of [HandlerSocket] (https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL) for [MySQL] (http://www.mysql.com).
### Installation
1. Configure nginx with option --add-module=/full/path/to/dir/nginx_http_handlersocket_json_module
2. make
3. sudo make install### Configuration
Configuration options should be used in a location context of nginx config file.
#### Example 1
location ~ /cities/(.+)/$ {
hs_json; # enable modulehs_json_host 127.0.0.1; # IP address of MySQL server (127.0.0.1 by default)
hs_json_port 9998; # port at which HandlerSocket is listening (9998 by default)hs_json_db test; # database name
hs_json_table city; # table namehs_json_index name; # index name (PRIMARY key is used by default)
hs_json_fields name,id; # fields to include in outpuths_json_op "="; # operator ("=" by default)
# possible values: =, <, <=, >, >=
hs_json_limit 10; # maximum number of records to be returned (10 by default)set $hs_request $1; # the set source input data
}This example will produce the following output:
curl http://localhost/cities/san/
[{"name":"San Amaro", "id": "12"},{"name":"San Andreas", "id": "13"},{"name":"San Andrs", "id": "14"} ... ]#### Example 2
Setting GET variable as a search parameter:
location ~ /json {
set $hs_request $get_id;
}### Errors
* 500 — incorrect configuration or some sort of protocol misbehaviour/misconfiguration or HadlerSocket error
* 503 — IO error or connection error while trying to connect to HandlerSocketIn case of empty set error 404 will NOT be returned. Instead an empty JSON response ({[]}) will be generated.
### Limitations* Output data size is limited to 1Kb. You can increase this limit by changing BUFF_SIZE constant (`#define BUFF_SIZE`).
* Only one field can be used as search criteria.### More info
[Original description at Habrahabr] (http://habrahabr.ru/blogs/nginx/115920/) (in Russian).