utils

package
v0.0.0-...-437e729 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateStruct

func ValidateStruct(s interface{}) error

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, statusCode int, response JSONResponse)

Types

type ErrorResponse

type ErrorResponse struct {
	Status  bool        `json:"status"`
	Message string      `json:"message,omitempty"`
	Errors  interface{} `json:"errors,omitempty"`
}

func UnmarshalRequest

func UnmarshalRequest(r *http.Request, v interface{}) *ErrorResponse

func (*ErrorResponse) GetMessage

func (er *ErrorResponse) GetMessage() string

func (*ErrorResponse) GetStatus

func (er *ErrorResponse) GetStatus() bool

type JSONResponse

type JSONResponse interface {
	GetStatus() bool
	GetMessage() string
}

type SuccessResponse

type SuccessResponse struct {
	Status  bool        `json:"status"`
	Message string      `json:"message,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

func (*SuccessResponse) GetMessage

func (sr *SuccessResponse) GetMessage() string

func (*SuccessResponse) GetStatus

func (sr *SuccessResponse) GetStatus() bool

Jump to

Keyboard shortcuts

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