Skip to content

beibeiabeibei/cast

This branch is up to date with xiaojiaoyu100/cast:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

98cdfc1 · Jun 2, 2021

History

90 Commits
May 21, 2019
Sep 15, 2019
Sep 12, 2019
May 6, 2018
Aug 14, 2020
May 30, 2018
Sep 12, 2019
May 21, 2019
Feb 6, 2020
Jan 2, 2019
Jun 2, 2021
Sep 12, 2019
Nov 3, 2019
Jan 2, 2019
Jun 6, 2018
Jun 6, 2018
Sep 17, 2020
Jun 2, 2021
Dec 10, 2019
May 21, 2019
Nov 3, 2019
Sep 15, 2019
Feb 25, 2020
Jun 16, 2020
Jun 16, 2020
Mar 12, 2020
May 30, 2018
Jan 3, 2019
Feb 25, 2020
Sep 12, 2019
May 28, 2018
Jun 13, 2018
Nov 3, 2019
May 7, 2019

Repository files navigation

cast

Build Status Go Report Card GoDoc

Cast is a http request library written in Golang.

This project is ready for production use and the master branch is always stable. But the API may be broken in the future release.

Getting started

dep ensure -add github.com/xiaojiaoyu100/cast

Usage

Generate a Cast

c, err := cast.New(cast.WithBaseURL("https://status.github.com"))

Generate a request

request := c.NewRequest()

Get

request := c.NewRequest().Get().WithPath("/api.json")
response, err := c.Do(request)

POST X-WWW-FORM-URLENCODED

request := c.NewRequest().Get().WithPath("/api.json").WithFormURLEncodedBody(body)
resp, err := c.Do(request)

POST JSON

request := c.NewRequest().Post().WithPath("/api.json").WithJSONBody(body)
response, err := c.Do(request)

POST XML

request := c.NewRequest().Post().WithPath("/api.json").WithXMLBody(body)
response, err := c.Do(request)

POST MULTIPART FORM DATA

request := c.NewRequest().Post().WithPath("/api.json").WithMultipartFormDataBody(formData)
resp, err := c.Do(request)

Timeout

c.NewRequest().WithTimeout(3 * time.Second)

Retry

cast.WithRetry(3)

Backoff

cast.WithXXXBackoffStrategy()

License

MIT License

Packages

No packages published

Languages

  • Go 100.0%