From 2e4951de58603a9f95063cff05635218f33891ae Mon Sep 17 00:00:00 2001 From: Tom Hudson Date: Thu, 10 Dec 2015 09:43:51 -0500 Subject: [PATCH] Adds LICENSE, updates examples --- .travis.yml | 10 ++++++++++ LICENSE | 12 ++++++++++++ README.mkd | 11 +++++++++-- examples_test.go | 8 +++++--- 4 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 .travis.yml create mode 100644 LICENSE diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..cbe9eb7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: go + +go: + - 1.0 + - 1.1 + - 1.2 + - 1.3 + - 1.4 + - 1.5 + - tip diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..07e245c --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2015 Tom Hudson + +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. diff --git a/README.mkd b/README.mkd index 4461589..15925ca 100644 --- a/README.mkd +++ b/README.mkd @@ -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 := "; rel=\"next\", ; rel=\"last\"" +header := "; rel=\"next\"," + + "; 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 ``` diff --git a/examples_test.go b/examples_test.go index 6f553f8..65a75a1 100644 --- a/examples_test.go +++ b/examples_test.go @@ -7,7 +7,8 @@ import ( ) func ExampleParse() { - header := "; rel=\"next\", ; rel=\"last\"" + header := "; rel=\"next\"," + + "; 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 := "; rel=\"next\", ; rel=\"last\"" +func ExampleLinks_FilterByRel() { + header := "; rel=\"next\"," + + "; rel=\"last\"" links := linkheader.Parse(header) for _, link := range links.FilterByRel("last") {