Skip to content

Lightweight and fast fluent interface wrapper over Http Client

License

Notifications You must be signed in to change notification settings

kunal-saini/httpman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

httpman

httpman

httpman is Lightweight and fast fluent interface wrapper over Http Client to make REST calls easier

Features

  • Fluent request building, Add or Set Request Headers/Query
  • Extendability to different endpoints
  • Encode structs and key value pair into URL query
  • Encode JSON payload into request
  • Decode JSON success or failure responses
  • Request retries [To Do]
  • Fake HTTP responses for testing [To Do]
  • File Message Store [To Do]

Usage

import "github.com/kunal-saini/httpman"

Examples

        resMap := make(map[string]interface{})
	errMap := make(map[string]interface{})

	type QueryParams struct {
		Foo string `url:"foo"`
	}

	client := httpman.
		New("https://example.com/").
		AddQueryStruct(&QueryParams{Foo: "bar"}).
		AddHeader("X-Key", "value")

	req, err := client.
		NewRequest().
		Get("path/to/resource").
		AddQueryParam("resource_key", "value").
		SetHeader("X-Resource-Key", "value").
		Decode(&resMap, &errMap)

About

Lightweight and fast fluent interface wrapper over Http Client

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages