https://github.com/wizardone/parser
Parsing urls against a set of rules.
https://github.com/wizardone/parser
elixir mix parsing rules
Last synced: 3 months ago
JSON representation
Parsing urls against a set of rules.
- Host: GitHub
- URL: https://github.com/wizardone/parser
- Owner: wizardone
- Created: 2016-12-21T08:03:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-28T14:00:46.000Z (almost 8 years ago)
- Last Synced: 2025-03-26T06:47:00.292Z (3 months ago)
- Topics: elixir, mix, parsing, rules
- Language: Elixir
- Homepage:
- Size: 11.7 KB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UrlParser
[](https://travis-ci.org/wizardone/parser)A small service that parses the whole request body (currently it is working only with the query params), it is meant to run the
whole request against a set of rules (as anonymous functions) and determine where to redirect the
request body.
This is my first ever elixir project, so I intent to extend it more and make it more usable.## Usage
```elixir
# Start the process, that will hold the rules
UrlParser.Rule.start_agent# Add some rules
function = fn(request) -> String.match?(request, ~r/query/) end
UrlParser.Rule.add(:query, function)uri = "http://test.com/?query=omg"
# If the url satisfies the rule
UrlParser.parse(uri)
=> [ok: :query]# If the url does not satisfy the rule.
UrlParser.parse(uri)
=> [{:not_ok, "Rules do not match"}]
```## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed as:
1. Add `url_parser` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:url_parser, "~> 0.1.0"}]
end
```2. Ensure `url_parser` is started before your application:
```elixir
def application do
[applications: [:url_parser]]
end
```