Adds LICENSE, updates examples

This commit is contained in:
Tom Hudson 2015-12-10 09:43:51 -05:00
parent d543c15203
commit 2e4951de58
4 changed files with 36 additions and 5 deletions

10
.travis.yml Normal file
View 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
View 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.

View File

@ -2,15 +2,22 @@
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
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)
for _, link := range links {
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
```

View File

@ -7,7 +7,8 @@ import (
)
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)
for _, link := range links {
@ -35,8 +36,9 @@ func ExampleParseMultiple() {
// URL: https://api.github.com/user/58276/repos?page=2; Rel: last
}
func ExampleFilterByRel() {
header := "<https://api.github.com/user/58276/repos?page=2>; rel=\"next\", <https://api.github.com/user/58276/repos?page=2>; rel=\"last\""
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\""
links := linkheader.Parse(header)
for _, link := range links.FilterByRel("last") {