common

package
v0.0.0-...-6270ec6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HEADERS_TO_IGNORE = []string{
	"authorization",
	"connection",
	"x-amzn-trace-id",
	"user-agent",
	"expect",
	"presigned-expires",
	"range",
}

HEADERS_TO_IGNORE contains headers to be ignored while signing request

View Source
var HEADERS_TO_INCLUDE = []string{"host", "x-fp-.*"}

HEADERS_TO_INCLUDE contains headers to be included while signing request

Functions

This section is empty.

Types

type FDKError

type FDKError struct {
	// Message is user-friendly message that can be displayed on front-end for end-users
	Message string `json:"message"`

	// Status is HTTP status code that is set in API response
	Status int `json:"status"`

	// A Code should be unique and used only once throughout the project
	// so that it can lead to the exact line of failed function when searched in the entire project.
	Code string `json:"code"`

	// Exception is technical expection title. This should be mostly 2-3 words title of the
	// error/er to be understood by developers.
	Exception string `json:"exception"`

	// Info is link/URL to the logging system(Sentry/Kibana) to get more insight and trace error
	Info string `json:"info"`

	// RequestID is the unique ID of a particular request for tracing the errors in the logging system(Sentry/Kibana)
	RequestID string `json:"request_id,omitempty"`

	//StackTrace gives the report of the active stack frames at a certain point in time during the execution of a program used for debugging purposes
	StackTrace string `json:"stack_trace,omitempty"`

	//Meta can be used for your custom keys, which would be helpful for detailed error and for debugging
	Meta objx.Map `json:"meta,omitempty"`
}

FDKError is custom error type to pass more information along with the native error.

func NewFDKError

func NewFDKError(message string) *FDKError

NewFDKError constructs and returns new FDKError object

func (*FDKError) Error

func (f *FDKError) Error() string

Error returns technical error message with error code and er title

func (*FDKError) SetRequestID

func (f *FDKError) SetRequestID(requestID string) *FDKError

SetRequestID sets the RequestID in the error object

func (*FDKError) SetStatus

func (f *FDKError) SetStatus(httpStatus int) *FDKError

SetStatus sets the HTTP Status in the error object

func (*FDKError) String

func (f *FDKError) String() string

type Paginator

type Paginator struct {
	PageNo      float64
	HasNextPage bool
	NextID      string
	Next        func() (interface{}, error)
}

Paginator holds paginator object

func NewPaginator

func NewPaginator(pageType string) *Paginator

NewPaginator returns paginator instance

func (*Paginator) HasNext

func (p *Paginator) HasNext() bool

HasNext return has_next value

func (*Paginator) SetPaginator

func (p *Paginator) SetPaginator(hasNext bool, pageNo int, nextID string)

SetPaginator sets paginator instance with either next_id or page_no

type RequestSigner

type RequestSigner struct {
	UpdatedReq        *http.Request
	RequestedDateTime string
	SignQuery         bool
}

RequestSigner holds request signer object

func NewRequestSigner

func NewRequestSigner(req *http.Request, signQuery bool) *RequestSigner

NewRequestSigner return the request signer instance

func (*RequestSigner) GetRequestedDateTime

func (r *RequestSigner) GetRequestedDateTime() string

GetRequestedDateTime reuse and returns the date time created

func (*RequestSigner) GetUpdatedRequest

func (r *RequestSigner) GetUpdatedRequest() *http.Request

GetUpdatedRequest return the updated HTTP request

func (*RequestSigner) Sign

func (r *RequestSigner) Sign() error

Sign performs request signing operation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL