handler

package
v0.4.11 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 9 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 FailureRender added in v0.4.6

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

FailureRender renders a failed response and status code and respond to the client request.

func FailureWithCodeRender added in v0.4.6

func FailureWithCodeRender(ctx context.Context, w http.ResponseWriter, r *http.Request, err error, statusCode int) error

FailureWithCodeRender renders a failed response and custom status code and respond to the client 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 NotFoundRender added in v0.4.6

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

NotFoundRender renders a not found response and status code and respond to the client request.

func RemoveUnstructuredManagedFields added in v0.4.8

func RemoveUnstructuredManagedFields(
	ctx context.Context,
	yaml *unstructured.Unstructured,
) (*unstructured.Unstructured, error)

RemoveUnstructuredManagedFields remove managedFields information within a Unstructured

func Response

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

Response creates a standard API response renderer.

func SuccessRender added in v0.4.6

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

SuccessRender renders a success response and status code and respond to the client 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