URL matching rules library to connect URLs with resources
Project description
URL matching library that relates URLs with resources. Rules are defined using simple pattern definitions. It is simpler and faster than using regular expressions if the rules involves many domains.
To illustrate it with an example, imagine that you have several proxy servers and you want to route requests to the right one. You could define the following rules:
site1.com →︎ us_proxy
site2.com/uk →︎ uk_proxy
site2.com/ie →︎ ie_proxy
All URLs from site1.com should use the US proxy. The situation for site2.com URLs are different: if the path starts with /uk, then use the UK proxy, otherwise use the IE proxy. This library allows to create a matcher that can be used to match URLs with the right proxy using these rules.
Have a look to https://github.com/zytedata/url-matcher/blob/main/url_matcher/example.py for an example of usage.
The following files are useful to understand the pattern, the set of patterns and how they behave:
https://github.com/zytedata/url-matcher/blob/main/tests/fixtures/single_patterns.json
https://github.com/zytedata/url-matcher/blob/main/tests/fixtures/patterns.json
The full documentation can be found at https://url-matcher.readthedocs.io/
License is BSD 3-clause.
Documentation: https://url-matcher.readthedocs.io/
Source code: https://github.com/zytedata/url-matcher
Issue tracker: https://github.com/zytedata/url-matcher/issues
Developing
Setup your local Python environment via:
pip install -r requirements-dev.txt
pre-commit install
Now everytime you perform a git commit, these tools will run against the staged files:
black
isort
flake8
mypy
You can also directly invoke pre-commit run --all-files to run them without performing a commit.
Using sphinx-autobuild
When working on documentation, it is convenient to use sphinx-autobuild. First, run pip install -r docs/requirements.txt sphinx-autobuild. Then run
sphinx-autobuild docs docs/_build/html
and then open http://127.0.0.1:8000/ in a browser, to see the current version of docs. A process would be running in a background, watching for docs changes; when docs are changed, a build is started, and the web page is refreshed automatically when the build is finished.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file url-matcher-0.1.0.tar.gz
.
File metadata
- Download URL: url-matcher-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92abd3af8e52946cc589b98cfd729799801298f966176de8aac7bafcd29dac11 |
|
MD5 | 0da3e2938d9c08d790d92c36cdd0f8f7 |
|
BLAKE2b-256 | 0eaf44caae321408560cfa3fa789489d35a96d652016557ebe25987ea73ddf3a |
File details
Details for the file url_matcher-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: url_matcher-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a1934aff210f5a800dd702af692dbea5e5b1d9e660526f2f85c1cd578d26081 |
|
MD5 | 62002508c631f7010c6885e1f6086092 |
|
BLAKE2b-256 | 98e87267405e5fa58e9780b04dac92d146be5a1b1fe3ac7abb6ab902aa7cc087 |