Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thiamsantos/linkex
Encode and decode HTTP Link headers.
https://github.com/thiamsantos/linkex
Last synced: 4 days ago
JSON representation
Encode and decode HTTP Link headers.
- Host: GitHub
- URL: https://github.com/thiamsantos/linkex
- Owner: thiamsantos
- License: apache-2.0
- Created: 2018-04-26T20:16:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-05-07T14:40:52.000Z (over 6 years ago)
- Last Synced: 2024-10-12T16:31:59.928Z (about 1 month ago)
- Language: Elixir
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Linkex
[![Travis](https://img.shields.io/travis/thiamsantos/linkex.svg)](https://travis-ci.org/thiamsantos/linkex)
[![Hex.pm](https://img.shields.io/hexpm/v/linkex.svg)](https://hex.pm/packages/linkex)
[![Docs](https://img.shields.io/badge/hex-docs-green.svg)](https://hexdocs.pm/linkex)> Encode and decode HTTP Link headers.
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Contributing](#contributing)
- [License](#license)## Install
The package can be installed by adding `linkex` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:linkex, "~> 0.1.0"}
]
end
```## Usage
```elixir
iex> Linkex.encode("; rel="next", ; rel="last")
{:ok, %LinkHeader{
last: %Entry{
target:
%URI{
authority: "api.github.com",
fragment: nil,
host: "api.github.com",
path: "/user/13632762/repos",
port: 443,
query: "client_id=1&client_secret=2&page=3&per_page=100",
scheme: "https",
userinfo: nil
}
},
next: %Entry{
target:
%URI{
authority: "api.github.com",
fragment: nil,
host: "api.github.com",
path: "/user/13632762/repos",
port: 443,
query: "client_id=1&client_secret=2&page=2&per_page=100",
scheme: "https",
userinfo: nil
}
}
}}iex> Linkex.decode(%LinkHeader{
last: %Entry{
target:
%URI{
authority: "api.github.com",
fragment: nil,
host: "api.github.com",
path: "/user/13632762/repos",
port: 443,
query: "client_id=1&client_secret=2&page=3&per_page=100",
scheme: "https",
userinfo: nil
}
},
next: %Entry{
target:
%URI{
authority: "api.github.com",
fragment: nil,
host: "api.github.com",
path: "/user/13632762/repos",
port: 443,
query: "client_id=1&client_secret=2&page=2&per_page=100",
scheme: "https",
userinfo: nil
}
}
}){:ok, "; rel="next", ; rel="last"}
```## Contributing
See the [contributing file](CONTRIBUTING.md).
## License
[Apache License, Version 2.0](LICENSE) © [Thiago Santos](https://github.com/thiamsantos)