Skip to content

vithubati/go-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-core

This repository contains implementation of some core go libs

How to use

installing

    go get github.com/vithubati/go-core

Usage

Authenticator

  1. Add core module to import statement.
    import "github.com/vithubati/go -core/<package>
  1. Creat an authenticator for the client
    authenticator, err := NewBasicAuthenticator ( "username", "password")

Http Client

  1. Creating a client
    auth, _ := authenticator.NewBearerTokenAuthenticator("Test-TOKEN")
    client := New(WithAuthenticator(auth))
  1. Creating a request
    auth, _ := authenticator.NewBearerTokenAuthenticator("Test-TOKEN")
    client := New(WithAuthenticator(auth))
    params := url.Values{}
    params.Set("limit", "5")
    params.Set("size", "10")
    ctx := context.Background()
    url := "https://gobyexample.com/"
    req := client.RequestWithCtx(ctx, url, http.MethodGet, nil, params)
  1. Executing a request
    resp, err := client.Execute(req)