rest

package
v1.0.33 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeAndWriteResponse added in v1.0.24

func EncodeAndWriteResponse(i any, w *echo.Response, lc log.Logger) error

func WriteDefaultHttpHeader added in v1.0.19

func WriteDefaultHttpHeader(w http.ResponseWriter, ctx context.Context, statusCode int)

func WriteErrorResponse added in v1.0.24

func WriteErrorResponse(w *echo.Response, ctx context.Context, lc log.Logger, err errors.Error, requestId string) error

WriteErrorResponse writes Http header, encode error response with JSON format and writes to the HTTP response.

func WriteHttpContentTypeHeader added in v1.0.24

func WriteHttpContentTypeHeader(w http.ResponseWriter, ctx context.Context, statusCode int, contentType string)

Types

type BaseResponse added in v1.0.24

type BaseResponse struct {
	Versionable `json:",inline"`
	RequestId   string `json:"requestId,omitempty"`
	Message     string `json:"message,omitempty"`
	StatusCode  int    `json:"statusCode"`
}

BaseResponse defines the base content for response DTOs (data transfer objects).

func NewBaseResponse added in v1.0.24

func NewBaseResponse(requestId string, message string, statusCode int) BaseResponse

type HTTPSender

type HTTPSender interface {
	// SetHTTPRequestHeaders sets up http request headers
	SetHTTPRequestHeaders(httpRequestHeaders map[string]string)

	// SetSecretData sets up http secret header
	SetSecretData(name, valueKey, headerName, valuePrefix string)

	// HTTPPost sends http POST request with data
	HTTPPost(dic *di.Container, data any) errors.Error
}

HTTPSender is the interface for http requests

func NewHTTPSender

func NewHTTPSender(url string, mimeType string) HTTPSender

NewHTTPSender creates, initializes and returns a new instance of HTTPSender

type Versionable added in v1.0.24

type Versionable struct {
	ApiVersion string `json:"apiVersion" validate:"required"`
}

Versionable shows the API version in DTOs

func NewVersionable added in v1.0.24

func NewVersionable() Versionable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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