Skip to content

Commit

Permalink
implemented much more and better request information.
Browse files Browse the repository at this point in the history
context.request.url now returns the full url.
  • Loading branch information
DorianGray committed Feb 3, 2014
1 parent b63e17c commit 22bb460
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lusty-nginx-0.3-1.rockspec → lusty-nginx-0.4-0.rockspec
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package = "lusty-nginx"
version = "0.3-1"
version = "0.4-0"
source = {
url = "https://github.com/Olivine-Labs/lusty-nginx/archive/v0.3.tar.gz",
dir = "lusty-nginx-0.3"
url = "https://github.com/Olivine-Labs/lusty-nginx/archive/v0.4.tar.gz",
dir = "lusty-nginx-0.4"
}
description = {
summary = "Nginx plugin for lusty.",
Expand Down
2 changes: 1 addition & 1 deletion src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ return function(lusty)
}, lusty.context.__meta)

--split url at /
string.gsub(context.request.url, "([^/]+)", function(c) context.suffix[#context.suffix+1] = c end)
string.gsub(context.request.uri, "([^/]+)", function(c) context.suffix[#context.suffix+1] = c end)

return lusty:request(context)
end
Expand Down
24 changes: 22 additions & 2 deletions src/request.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,33 @@ return {
return request.params
end,

url = function(request)
uri = function(request)
return request.url or ngx.var.uri
end,

host = function(request)
return request.host or ngx.var.host
end,

port = function(request)
return request.port or ngx.var.server_port
end,

scheme = function(request)
return request.scheme or ngx.var.scheme
end,

url = function(request)
return request.url or ngx.var.scheme..'://'..ngx.var.host..(ngx.var.server_port == '80' and '' or ':'..ngx.var.server_port)..ngx.var.uri
end,

queryString = function(request)
return request.queryString or ngx.var.query_string
end,

sub = function(request)
return ngx.location.capture
end
end,
},
newindex = {
method = function(request, value)
Expand Down

0 comments on commit 22bb460

Please sign in to comment.