httputils

package
v0.0.0-...-80236ea Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package httputils is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValidator

func NewValidator(transcrib transcriber.Transcriber) *validator

NewValidator creates a new instance of validator with the provided transcriber.

Types

type ErrorDetail

type ErrorDetail struct {
	Error       bool   `json:"-"`
	FailedField string `json:"failed_field"`
	Tag         string `json:"criteria"`
	Value       any    `json:"value"`
	Message     string `json:"message"`
}

ErrorDetail represents detailed information about an error that occurred during validation.

type GlobalErrorHandlerResp

type GlobalErrorHandlerResp struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}

GlobalErrorHandlerResp represents the response structure for a global error handler.

type HTTPErrorHandler

type HTTPErrorHandler struct{}

HTTPErrorHandler is responsible for handling errors and formatting responses in a standardized way across the application.

func (HTTPErrorHandler) Response

func (h HTTPErrorHandler) Response(err error, c echo.Context)

Response handles the error response by logging the error and formatting the response to the client based on the type of error (generic error, Echo error, AppError).

type HTTPServer

type HTTPServer struct {
	App *echo.Echo

	ErrorHandler *HTTPErrorHandler
	// contains filtered or unexported fields
}

HTTPServer represents the HTTP server configuration and lifecycle management for the application, built using the Echo framework.

func New

func New(envValues *env.Values) *HTTPServer

New creates and configures a new HTTPServer instance with the provided environment values.

func (*HTTPServer) Cleanup

func (h *HTTPServer) Cleanup(ctx context.Context) error

Cleanup shuts down the HTTP server gracefully.

func (*HTTPServer) Start

func (h *HTTPServer) Start() error

Start begins the HTTP server and listens on the configured port.

type MockValidator

type MockValidator[C any] struct {
	// contains filtered or unexported fields
}

MockValidator is a mock of Validator interface.

func NewMockValidator

func NewMockValidator[C any](ctrl *gomock.Controller) *MockValidator[C]

NewMockValidator creates a new mock instance.

func (*MockValidator[C]) DecodeAndValidate

func (m *MockValidator[C]) DecodeAndValidate(c C, target any) error

DecodeAndValidate mocks base method.

func (*MockValidator[C]) EXPECT

func (m *MockValidator[C]) EXPECT() *MockValidatorMockRecorder[C]

EXPECT returns an object that allows the caller to indicate expected use.

type MockValidatorMockRecorder

type MockValidatorMockRecorder[C any] struct {
	// contains filtered or unexported fields
}

MockValidatorMockRecorder is the mock recorder for MockValidator.

func (*MockValidatorMockRecorder[C]) DecodeAndValidate

func (mr *MockValidatorMockRecorder[C]) DecodeAndValidate(c, target any) *gomock.Call

DecodeAndValidate indicates an expected call of DecodeAndValidate.

type Validator

type Validator[C any] interface {
	DecodeAndValidate(c C, target any) error
}

TODO

Jump to

Keyboard shortcuts

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