Skip to content

Commit

Permalink
Add go 1.19 to test matrix
Browse files Browse the repository at this point in the history
* Rename default branch from master to main
* Add badges to README
  • Loading branch information
dghubble committed Aug 11, 2022
1 parent 62be7c2 commit fac8477
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/test.yaml
Expand Up @@ -2,18 +2,16 @@ name: test
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
jobs:
build:
name: go
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: ['1.17', '1.18']
go: ['1.17', '1.18', '1.19']
steps:
- name: setup
uses: actions/setup-go@v3
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
# Sling [![Build Status](https://github.com/dghubble/sling/workflows/test/badge.svg)](https://github.com/dghubble/oauth1/actions?query=workflow%3Atest+branch%3Amaster) [![Coverage](https://gocover.io/_badge/github.com/dghubble/sling)](https://gocover.io/github.com/dghubble/sling) [![GoDoc](https://godoc.org/github.com/dghubble/sling?status.svg)](https://godoc.org/github.com/dghubble/sling)
# Sling [![GoDoc](https://pkg.go.dev/badge/github.com/dghubble/sling.svg)](https://pkg.go.dev/github.com/dghubble/sling) [![Workflow](https://github.com/dghubble/sling/actions/workflows/test.yaml/badge.svg)](https://github.com/dghubble/sling/actions/workflows/test.yaml?query=branch%3Amain) [![Coverage](https://gocover.io/_badge/github.com/dghubble/sling)](https://gocover.io/github.com/dghubble/sling) [![Sponsors](https://img.shields.io/github/sponsors/dghubble?logo=github)](https://github.com/sponsors/dghubble) [![Twitter](https://img.shields.io/badge/twitter-follow-1da1f2?logo=twitter)](https://twitter.com/dghubble)

<img align="right" src="https://storage.googleapis.com/dghubble/small-gopher-with-sling.png">

Expand Down
18 changes: 9 additions & 9 deletions doc.go
Expand Up @@ -5,7 +5,7 @@ Slings store HTTP Request properties to simplify sending requests and decoding
responses. Check the examples to learn how to compose a Sling into your API
client.
Usage
# Usage
Use a Sling to set path, method, header, query, or body properties and create an
http.Request.
Expand All @@ -18,7 +18,7 @@ http.Request.
req, err := sling.New().Get("https://example.com").QueryStruct(params).Request()
client.Do(req)
Path
# Path
Use Path to set or extend the URL for created Requests. Extension means the
path will be resolved relative to the existing URL.
Expand All @@ -31,14 +31,14 @@ except they set the HTTP method too.
req, err := sling.New().Post("http://upload.com/gophers")
Headers
# Headers
Add or Set headers for requests created by a Sling.
s := sling.New().Base(baseUrl).Set("User-Agent", "Gophergram API Client")
req, err := s.New().Get("gophergram/list").Request()
QueryStruct
# QueryStruct
Define url parameter structs (https://godoc.org/github.com/google/go-querystring/query).
Use QueryStruct to encode a struct as query parameters on requests.
Expand All @@ -59,7 +59,7 @@ Use QueryStruct to encode a struct as query parameters on requests.
params := &IssueParams{Sort: "updated", State: "open"}
req, err := githubBase.New().Get(path).QueryStruct(params).Request()
Json Body
# Json Body
Define JSON tagged structs (https://golang.org/pkg/encoding/json/).
Use BodyJSON to JSON encode a struct as the Body on requests.
Expand All @@ -83,7 +83,7 @@ Use BodyJSON to JSON encode a struct as the Body on requests.
Requests will include an "application/json" Content-Type header.
Form Body
# Form Body
Define url tagged structs (https://godoc.org/github.com/google/go-querystring/query).
Use BodyForm to form url encode a struct as the Body on requests.
Expand All @@ -100,7 +100,7 @@ Use BodyForm to form url encode a struct as the Body on requests.
Requests will include an "application/x-www-form-urlencoded" Content-Type
header.
Plain Body
# Plain Body
Use Body to set a plain io.Reader on requests created by a Sling.
Expand All @@ -109,7 +109,7 @@ Use Body to set a plain io.Reader on requests created by a Sling.
Set a content type header, if desired (e.g. Set("Content-Type", "text/plain")).
Extend a Sling
# Extend a Sling
Each Sling generates an http.Request (say with some path and query params)
each time Request() is called, based on its state. When creating
Expand Down Expand Up @@ -137,7 +137,7 @@ is undesired.
Recap: If you wish to extend a Sling, create a new child copy with New().
Receive
# Receive
Define a JSON struct to decode a type from 2XX success responses. Use
ReceiveSuccess(successV interface{}) to send a new Request and decode the
Expand Down
6 changes: 3 additions & 3 deletions sling.go
Expand Up @@ -55,9 +55,9 @@ func New() *Sling {
// New returns a copy of a Sling for creating a new Sling with properties
// from a parent Sling. For example,
//
// parentSling := sling.New().Client(client).Base("https://api.io/")
// fooSling := parentSling.New().Get("foo/")
// barSling := parentSling.New().Get("bar/")
// parentSling := sling.New().Client(client).Base("https://api.io/")
// fooSling := parentSling.New().Get("foo/")
// barSling := parentSling.New().Get("bar/")
//
// fooSling and barSling will both use the same client, but send requests to
// https://api.io/foo/ and https://api.io/bar/ respectively.
Expand Down

0 comments on commit fac8477

Please sign in to comment.