Skip to content

Releases: ysyesilyurt/go-restclient

Add Builder Pattern and Separate the Legacy Part

03 Jul 00:56
Compare
Choose a tag to compare

With this release now go-restclient has its own request builder for building HTTP requests neatly and then making the actual calls elegantly.

A huge part of legacy go-restclient codebase has been refactored and migrated to a new branch called legacy for archiving and reusing purposes.

Happy, elegant and short request cycles 🙂 !

go-restclient v0.1.1

05 Apr 20:29
Compare
Choose a tag to compare

v0.1.1

Fixed module description in go.mod, renamed go-restclient module name to github.com/ysyesilyurt/go-restclient

go-restclient v0.1.0

03 Apr 18:37
Compare
Choose a tag to compare

v0.1.0

As this is the first release of go-restclient, its feature set pretty much contains everything that are intended as default for go-restclient implementation, which are in general:

With restclient.NewRequest(...)

  • Constructing URL by escaping path components
  • Marshaling RequestBody if exists
  • Building the request object
  • Validating that resulting URI is valid
  • Setting queryParams if exists
  • Setting custom headers

After calling client.Get(...) on client := restclient.NewHttpClient()

  • Setting universal headers
  • Setting Authorization header by applying specified authenticator's strategy
  • Setting context timeout and defer its cancellation
  • Doing Request (Timing and Logging it if needed)
  • Handling Response Status Code
  • Reading the body and unmarshal it into given value

Wrappers

There also exists wrappers for usage convenience which converts below code piece:

ri := NewRequestInfo(scheme, host, ...) // or NewRequestInfoFromRawURL(rawURL, ...)
req, err := NewRequest(ri)
if err != nil {
	...
}
client := NewHttpClient(true, 30 * time.Second)
dri := NewDoRequestInfo(req, auth, &responseRef) // or NewDoRequestInfoWithTimeout(..., ..., ..., requestTimeout)
err = client.Get(dri)
if err != nil {
	...
}

Into this one:

ri := NewRequestInfo(scheme, host, ...) // or NewRequestInfoFromRawURL(rawURL, ...)
err := restclient.PerformGetRequest(ri, auth, &response, true, 30 * time.Second)
if err != nil {
	...
}

Tests

There also exists carious tests (client_test, request_test) and assertions implemented to validate and verify that go-restclient works.