handler

package
v0.0.0-...-e5cb43e Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupCorsOriginHeader

func SetupCorsOriginHeader(w *http.ResponseWriter, req *http.Request)

SetupCorsOriginHeader sets the CORS headers for the response.

  • Use this function for all the public APIs.

func WriteJsonResp

func WriteJsonResp(w http.ResponseWriter, err error, respBody interface{}, status int)

WriteJsonResp writes the response in JSON format.

  • Use this function for writing the response for all the APIs.

Types

type ApiError

type ApiError struct {
	HttpStatusCode    int         `json:"-"`
	Code              string      `json:"code,omitempty"`
	InternalMessage   string      `json:"internalMessage,omitempty"`
	UserMessage       interface{} `json:"userMessage,omitempty"`
	UserDetailMessage string      `json:"userDetailMessage,omitempty"`
}

ApiError represents an error response

func NewApiError

func NewApiError(httpStatusCode int, userMessage, internalMessage string) *ApiError

NewApiError creates a new ApiError object

func (*ApiError) Error

func (e *ApiError) Error() string

Error returns the internal message

type Response

type Response struct {
	Code   int         `json:"code,omitempty"`
	Status string      `json:"status,omitempty"`
	Result interface{} `json:"result,omitempty"`
	Errors []*ApiError `json:"errors,omitempty"`
}

Response represents a generic API response

Jump to

Keyboard shortcuts

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