github.com/dforsyth/reflectclient

A simple (experimental) HTTP client for Go.


Keywords
experimental, go, golang, http, incomplete
Install
go get github.com/dforsyth/reflectclient

Documentation

An experiment in building simple HTTP clients (in the spirit of Retrofit and Feign) using tags and reflection.

How it works:

// Declare your service
type UserId struct {
    Id int64 `feature:"path" name:"id"`
}
type Service struct {
    User func(int) (User, error) `method:"GET" path:"/user/{0}"`
    UserByStruct func(*UserId) (User, error) `method:"GET" path:"/user/{id}"`
}

// Build your client
client, err := reflectclient.NewBuilder().BaseUri("https://api.somesite.com").Build()

// Initialize your service
service := new(Service)
client.Init(service)

// Call stuff
user, err := service.User(15)
user, err := service.UserByStruct(&UserId{Id: 15})