Awesome
lua-resty-url
lua-resty-url - URL parser for OpenResty.
Table of Contents
- Name
- Status
- Description
- Synopsis
- Methods
- Installation
- TODO
- Community
- Bugs and Patches
- Author
- Copyright and License
- See Also
Status
This library is considered production ready.
Description
This Lua library is very simple Regex based URL parser.
This library can parse URLs and split them to components.
Synopsis
http {
server {
location /test {
content_by_lua_block {
local resty_url = require 'resty.url'
ngx.say("USER: ", resty_url.parse('http://foo:bar@example.com').user)
}
}
}
}
Methods
All the methods are expected to be called on the module without self.
split
syntax: parts = resty_url.split(url)
Returns a table with integer keys and parts of the URL. Components are: scheme, user, password, host, port, path.
parse
syntax: uri = resty_url.parse(url)
Returns a table with components as keys. Components are: scheme, user, password, host, port, path.
join
syntax: url = resty_url.join(base, part, ...)
Concatenates URI components into resulting URL. Also normalizes URI to remove double slashes.
Can concatenate objects returned by parse
method.
default_port
syntax: port = resty_url.default_port(scheme)
Returns default port for given scheme. Only http and https provided by default.
normalize
syntax: uri = resty_url.normalize(uri)
Removes unnecessary slashes from the URI.
Installation
If you are using the OpenResty bundle (http://openresty.org ), then you can use opm to install this package.
opm get 3scale/lua-resty-url
Bugs and Patches
Please report bugs or submit patches by
- creating a ticket on the GitHub Issue Tracker,
Author
Michal "mikz" Cichra mcichra@redhat.com, Red Hat Inc.
Copyright and License
This module is licensed under the Apache License Version 2.0.
Copyright (C) 2016-2017, Red Hat Inc.
All rights reserved.
See LICENSE for the full license.
See Also
- the APIcast API Gateway: https://github.com/3scale/apicast/#readme