Skip to content

Mofiqul/gaxios

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A http client in Golang inspired from nodejs axios

Installation

go get github.com/mofiqul/gaxios

Read the Documentation

Example

type ResponseData struct {
	Message string `json:"message"`
}

res, err := gaxios.Get(fmt.Sprintf("%s/test", server.URL), &gaxios.GAxiosConfig{
	Header: http.Header{
		"Accept": []string{"application/json"},
	},
}) 
defer res.Data.Close()
if err != nil {
	// Handle error
}

resp := &ResponseData{}
_ = json.NewDecoder(res.Data).Decode(resp)

Or create a instance with configuation

var axios = gaxios.New( 
	&gaxios.GAxiosConfig{
		Header: http.Header{
			"Accept": []string{"application/json"},
		},
	})

res, err := axios.Get(fmt.Sprintf("%s/test", server.URL))
defer res.Data.Close()
if err != nil {
	// Handle error
}

resp := &ResponseData{}
_ = json.NewDecoder(res.Data).Decode(resp)

About

Axios like http client for golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages