util

package
v0.7.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2022 License: MPL-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Prefix    string = "CO"
	Seperator string = "."
)

Variables

View Source
var (
	VersionStr = "build-without-version-string"
	GitCommit  = "build-without-git-commit"
)
View Source
var ErrEmptyBody = errors.New("body must not be empty")

Functions

func CleanEndpoint

func CleanEndpoint(s string) (string, error)

func ComputeJSONHmac

func ComputeJSONHmac(hash, data, secret string, order bool) (string, error)

func ConvertDefaultHeaderToCustomHeader

func ConvertDefaultHeaderToCustomHeader(h *http.Header) *datastore.HttpHeader

ConvertDefaultHeaderToCustomHeader converts http.Header to convoy.HttpHeader

func EndOfMonth

func EndOfMonth(t time.Time) time.Time

func GenerateAPIKey

func GenerateAPIKey() (string, string)

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

func GenerateSecret

func GenerateSecret() (string, error)

func IsJSON

func IsJSON(s string) bool

func IsStringEmpty

func IsStringEmpty(s string) bool

IsStringEmpty checks if the given string s is empty or not

func JsonReMarshalString

func JsonReMarshalString(s string) (string, error)

func MongoExportArgsBuilder added in v0.6.0

func MongoExportArgsBuilder(uri string, collection string, query string, out string) []string

func ReadJSON

func ReadJSON(r *http.Request, dst interface{}) error

func StartOfMonth

func StartOfMonth(t time.Time) time.Time

func Validate

func Validate(dst interface{}) error

Types

type DBExporter added in v0.6.0

type DBExporter interface {
	Export() (int64, error)
}

type MongoExporter added in v0.6.0

type MongoExporter struct {
	Args []string
}

func (*MongoExporter) Export added in v0.6.0

func (me *MongoExporter) Export() (int64, error)

type Response added in v0.6.2

type Response struct {
	StatusCode int `json:"-"`
}

func (Response) Render added in v0.6.2

func (res Response) Render(w http.ResponseWriter, r *http.Request) error

type ServerResponse added in v0.6.2

type ServerResponse struct {
	Response
	Status  bool            `json:"status"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

func NewErrorResponse added in v0.6.2

func NewErrorResponse(msg string, statusCode int) ServerResponse

func NewServerResponse added in v0.6.2

func NewServerResponse(msg string, object interface{}, statusCode int) ServerResponse

func NewServiceErrResponse added in v0.6.2

func NewServiceErrResponse(err error) ServerResponse

type ServiceError added in v0.6.2

type ServiceError struct {
	// contains filtered or unexported fields
}

func NewServiceError added in v0.6.2

func NewServiceError(errCode int, errMsg error) *ServiceError

func (*ServiceError) ErrCode added in v0.6.2

func (s *ServiceError) ErrCode() int

func (*ServiceError) Error added in v0.6.2

func (s *ServiceError) Error() string

type Signature added in v0.7.0

type Signature struct {
	Timestamp   string
	Hmac        string
	EncodedData []byte
}

func GenerateSignatureHeader added in v0.7.0

func GenerateSignatureHeader(replayAttacks bool, hash string, secret string, data json.RawMessage) (*Signature, error)

Jump to

Keyboard shortcuts

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