Skip to content

Latest commit

 

History

History
60 lines (43 loc) · 1.42 KB

README.md

File metadata and controls

60 lines (43 loc) · 1.42 KB

Test Coverage Status Go Report Card

Read documentation here.

How to use

Create configuration

apiCall := apicall.New(
    WithBaseUrl("https://www.google.pt"),
)

Tip: You can create your own method for configuration, you only need to implement Option type.

Handler Response

response, err := apiCall.Send("GET", "/users/list", nil)  
if err != nil {
    panic("An error happen")
}

if !response.IsOk() {
    panic("Unable to success response")
}

fmt.Println(response) // response is apicall.BaseStandard struct

Bind your own structure to response

response, err := apiCall.Send("POST", "/get-users", nil)
if err != nil {
    panic("An error happen")
}

if !response.IsOk() {
    panic("Unable to success response")
}

type User struct {
    Name string
    Email string
}

var users []User
err = response.GetItems(&users)

for index, user := range users {
    fmt.Println(user.Name)
}