util

package
v0.0.0-...-7940cbf Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyBody = errors.New("body must not be empty")

Functions

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 GenerateRandomString

func GenerateRandomString(n int) (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 NewDateTime

func NewDateTime() *primitive.DateTime

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 Response

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

func (Response) Render

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

type ServerResponse

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

func NewErrorResponse

func NewErrorResponse(msg string, statusCode int) ServerResponse

func NewServerResponse

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

func NewServiceErrResponse

func NewServiceErrResponse(err error) ServerResponse

type ServiceError

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

func NewServiceError

func NewServiceError(errCode int, errMsg error) *ServiceError

func (*ServiceError) ErrCode

func (s *ServiceError) ErrCode() int

func (*ServiceError) Error

func (s *ServiceError) Error() string

Jump to

Keyboard shortcuts

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