handler

package
v0.3.28 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SuccessMessage = "OK"

SuccessMessage is the default success message for successful responses.

Variables

This section is empty.

Functions

func FailureResponse

func FailureResponse(ctx context.Context, err error) render.Renderer

FailureResponse creates a response renderer for a failed request.

func HandleResult

func HandleResult(w http.ResponseWriter, r *http.Request, ctx context.Context, err error, data any)

HandleResult is a handler function that writes the response to the HTTP response writer based on the provided error and data.

func Response

func Response(ctx context.Context, data any, err error) render.Renderer

Response creates a standard API response renderer.

func SuccessResponse

func SuccessResponse(ctx context.Context, data any) render.Renderer

SuccessResponse creates a response renderer for a successful request.

Types

type Duration

type Duration time.Duration

Duration is a custom type that represents a duration of time.

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() (b []byte, err error)

MarshalJSON customizes JSON representation of the Duration type.

type Payload

type Payload interface {
	Decode(*http.Request) error // Decode returns the payload object with the decoded
}

Payload is an interface for incoming requests payloads Each handler should implement this interface to parse payloads

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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