Website Blog

Vegeta - A Simple Golang Wrapper for connecting to APIs

A lot of application development these days has to do with connecting to APIs. This means however different the underlying service we all end up implementing the same authentication mechanisms over and over, which is why I decided to go ahead and implement a simple library in Go, vegeta

The library is very simple and is centered around the Handler object.

type Handler struct {
	Token    string
	User     string
	Password string
	Headers  map[string]string
	Request  http.Request

As you can observe the exposed fields are the standard ones that are used in making most API calls. The Handler object can be initiated by calling the NewHandler function

func NewHandler() *Handler {
	return &Handler{Headers: make(map[string]string)}

Once the fields are set up, you can jsut make a call to the method GetRequest

func (h *Handler) GetRequest(url string) (output []byte, err error)

The library is nowhere near completion. I plan on developing it as is needed. Let me know if you have feedback by opening an issue on the repo.