Home >Backend Development >PHP Tutorial >nginx nginx returns json
1. Format
location ~ /query { default_type application/json; return 200 '{"res":{"code":"0","message":"","value":"$value"}}'; }
3. If you need to return different values based on request parameters, you can consider using map,
map_hash_bucket_size 128; map $args $value{ default 2; include /usr/local/nginx-1.8.1/map/query.map; }
#query.map arg=querytest 1; arg=query 0;
The above introduces nginx nginx returns json, including nginx content. I hope it will be helpful to friends who are interested in PHP tutorials.