restapi

package
v1.0.5-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidParameter defines the invalid parameter error.
	ErrInvalidParameter = echo.NewHTTPError(http.StatusBadRequest, "invalid parameter")

	// ErrServiceNotImplemented defines the service not implemented error.
	ErrServiceNotImplemented = echo.NewHTTPError(http.StatusNotImplemented, "service not implemented")
)

Functions

func JSONResponse

func JSONResponse(c echo.Context, statusCode int, result interface{}) error

JSONResponse wraps the result into a "data" field and sends the JSON response with status code.

Types

type AllowedRoute

type AllowedRoute func(echo.Context) bool

AllowedRoute defines a function to allow or disallow routes.

type HTTPErrorResponse

type HTTPErrorResponse struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

HTTPErrorResponse defines the error struct for the HTTPErrorResponseEnvelope.

type HTTPErrorResponseEnvelope

type HTTPErrorResponseEnvelope struct {
	Error HTTPErrorResponse `json:"error"`
}

HTTPErrorResponseEnvelope defines the error response schema for node API responses.

type HTTPOkResponseEnvelope

type HTTPOkResponseEnvelope struct {
	// The response is encapsulated in the Data field.
	Data interface{} `json:"data"`
}

HTTPOkResponseEnvelope defines the ok response schema for node API responses.

Jump to

Keyboard shortcuts

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