httplib

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrefixBearer = "Bearer "
)

Variables

View Source
var CookieName = "session"

Functions

func ErrorResponseJSON

func ErrorResponseJSON(w http.ResponseWriter, httpCode int, internalCode int, err error)

Sends error http response

func ExtractTokenFromRequest added in v0.4.0

func ExtractTokenFromRequest(r *http.Request) (string, error)

func GetAuthorizationTokenFromRequestHeader

func GetAuthorizationTokenFromRequestHeader(r *http.Request, prefix string) string

func GetDeviceTypeFromRequestHeaders

func GetDeviceTypeFromRequestHeaders(r *http.Request) string

GetDeviceTypeFromRequestHeaders

func GetLimitAndOffsetFromPageNumber

func GetLimitAndOffsetFromPageNumber(page, limit int) (int, int)

func GetLimitAndOffsetFromRequest

func GetLimitAndOffsetFromRequest(r *http.Request) (int, int)

func GetPagingInt32FromPageNumber

func GetPagingInt32FromPageNumber(page, limit int) (int32, int32)

func GetPagingInt32FromRequest

func GetPagingInt32FromRequest(r *http.Request) (int32, int32)

func GetPagingInt64FromPageNumber

func GetPagingInt64FromPageNumber(page, limit int) (int64, int64)

func GetPagingInt64FromRequest

func GetPagingInt64FromRequest(r *http.Request) (int64, int64)

func ResponseJSON

func ResponseJSON(w http.ResponseWriter, v interface{})

Sends OK JSON response

func SetCookieName added in v0.4.0

func SetCookieName(name string)

SetCookieName sets value of the CookieName package variable

func SuccessfulResultMap

func SuccessfulResultMap() map[string]interface{}

Types

type ApiError

type ApiError struct {
	HttpStatus int         `json:"http_status,omitempty"`
	ErrorCode  int         `json:"code"`
	Message    interface{} `json:"message"`
	Timestamp  interface{} `json:"timestamp"`
}

func NewApiError

func NewApiError(code int, msg string) *ApiError

func (ApiError) Error

func (e ApiError) Error() string

func (ApiError) String

func (e ApiError) String() string

type CreatedObjectId

type CreatedObjectId struct {
	Id   interface{} `json:"id,omitempty" yaml:"id,omitempty"`
	UUID interface{} `json:"uuid,omitempty" yaml:"uuid,omitempty"`
}

type Interceptor added in v1.3.1

type Interceptor struct {
	Router *mux.Router
	Tracer opentracing.Tracer
	Logger *zap.SugaredLogger
	// contains filtered or unexported fields
}

Interceptor

func NewInterceptor added in v1.3.1

func NewInterceptor(lg *zap.SugaredLogger, j *tracing.Jaeger, tlsConf *tls.Config) *Interceptor

func (*Interceptor) ServeHTTP added in v1.3.1

func (i *Interceptor) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP

type ListResult

type ListResult struct {
	Results interface{} `json:"results,omitempty" yaml:"results,omitempty"`
	Count   int32       `json:"count" yaml:"count"`
	HasPrev bool        `json:"has_prev" yaml:"has_prev"`
	HasNext bool        `json:"has_next" yaml:"has_next"`
}

type Response added in v0.1.3

type Response struct {
	Success   bool        `json:"success" yaml:"success"`
	Timestamp interface{} `json:"timestamp,omitempty" yaml:"timestamp,omitempty" `
	Message   interface{} `json:"message,omitempty" yaml:"message,omitempty"`
	Data      interface{} `json:"data,omitempty" yaml:"data,omitempty"`
	CreatedObjectId
	RequestStatus *ApiError `json:"request_status" yaml:"request_status,omitempty"`
}

func SuccessfulResult

func SuccessfulResult() Response

Jump to

Keyboard shortcuts

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