Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kemonomachi/yuri
Elixir module for easier URI manipulation.
https://github.com/kemonomachi/yuri
Last synced: 2 months ago
JSON representation
Elixir module for easier URI manipulation.
- Host: GitHub
- URL: https://github.com/kemonomachi/yuri
- Owner: kemonomachi
- License: wtfpl
- Created: 2015-02-07T15:35:40.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2020-03-03T16:33:37.000Z (almost 5 years ago)
- Last Synced: 2024-10-01T19:12:47.086Z (3 months ago)
- Language: Elixir
- Homepage:
- Size: 11.7 KB
- Stars: 13
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Simple struct for representing URIs. (HTTP)
- fucking-awesome-elixir - yuri - Simple struct for representing URIs. (HTTP)
- awesome-elixir - yuri - Simple struct for representing URIs. (HTTP)
README
YURI
====Simple struct for representing URIs.
Similar to the standard lib `URI` struct, but provides Dict-like acces
to the query string.##Usage
Add YURI to your `mix.exs` dependencies:
```elixir
def deps do
[{:yuri, "~> 1.0.0"}]
end
```Download and compile:
```sh-session
$ mix deps.get$ mix deps.compile
```Begin URI manipulation:
```elixir
uri = YURI.parse "http://www.example.com/example?a=1"#Or with optional Dict of query parameters:
uri = YURI.parse "http://www.example.com/example?a=1", %{"b" => 2, "c" => 3}to_string uri
#>> "http://www.example.com/example?a=1&b=2&c=3"uri
|> YURI.put("a", "one")
|> YURI.delete("b")
|> YURI.put("d", "IV")
|> to_string
#>> "http://www.example.com/example?a=one&c=3&d=IV"YURI.get uri, "a"
#>> "1"to_string {uri | path: "/example/new"}
#>> "http://www.example.com/example/new?a=1&b=2&c=3"uri.scheme
#>> "http"
```YURI implements the Dict behaviour, all functions in the Dict module
can be used to manipulate the query string. It also implements the
Enumerable, Collectable, String.Chars and List.Chars protocols.Other parts of the URI can be accessed using standard struct syntax.
##License
Copyright © 2015 Ookami <>
This work is free. You can redistribute it and/or modify it under the
terms of the Do What The Fuck You Want To Public License, Version 2,
as published by Sam Hocevar. See the LICENSE file or
[WTFPL homepage](http://www.wtfpl.net) for more details.