Adds LICENSE, updates examples
This commit is contained in:
parent
d543c15203
commit
2e4951de58
10
.travis.yml
Normal file
10
.travis.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
language: go
|
||||||
|
|
||||||
|
go:
|
||||||
|
- 1.0
|
||||||
|
- 1.1
|
||||||
|
- 1.2
|
||||||
|
- 1.3
|
||||||
|
- 1.4
|
||||||
|
- 1.5
|
||||||
|
- tip
|
12
LICENSE
Normal file
12
LICENSE
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
Copyright (c) 2015 Tom Hudson <mail@tomnomnom.com>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||||
|
IN THE SOFTWARE.
|
11
README.mkd
11
README.mkd
|
@ -2,15 +2,22 @@
|
||||||
|
|
||||||
Library for parsing HTTP Link headers.
|
Library for parsing HTTP Link headers.
|
||||||
|
|
||||||
## Example
|
Docs can be found on [the GoDoc page](https://godoc.org/github.com/TomNomNom/linkheader).
|
||||||
|
|
||||||
|
## Basic Example
|
||||||
|
|
||||||
```go
|
```go
|
||||||
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\", <https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\"," +
|
||||||
|
"<https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
||||||
links := linkheader.Parse(header)
|
links := linkheader.Parse(header)
|
||||||
|
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
fmt.Printf("URL: %s; Rel: %s\n", link.URL, link.Rel)
|
fmt.Printf("URL: %s; Rel: %s\n", link.URL, link.Rel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// URL: https://api.github.com/user/58276/repos?page=2; Rel: next
|
||||||
|
// URL: https://api.github.com/user/58276/repos?page=2; Rel: last
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExampleParse() {
|
func ExampleParse() {
|
||||||
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\", <https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\"," +
|
||||||
|
"<https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
||||||
links := linkheader.Parse(header)
|
links := linkheader.Parse(header)
|
||||||
|
|
||||||
for _, link := range links {
|
for _, link := range links {
|
||||||
|
@ -35,8 +36,9 @@ func ExampleParseMultiple() {
|
||||||
// URL: https://api.github.com/user/58276/repos?page=2; Rel: last
|
// URL: https://api.github.com/user/58276/repos?page=2; Rel: last
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExampleFilterByRel() {
|
func ExampleLinks_FilterByRel() {
|
||||||
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\", <https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\"," +
|
||||||
|
"<https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
|
||||||
links := linkheader.Parse(header)
|
links := linkheader.Parse(header)
|
||||||
|
|
||||||
for _, link := range links.FilterByRel("last") {
|
for _, link := range links.FilterByRel("last") {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user