util

package
v0.83.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: BSD-3-Clause Imports: 9 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteError

func WriteError(ctx context.Context, err error, w http.ResponseWriter)

WriteError converts an error to an JSON error response. If it is known internal error of type server.Error then it sets the messages from the error, a generic message otherwise

func WriteErrorResponse

func WriteErrorResponse(errMsg string, httpStatus int, w http.ResponseWriter)

WriteErrorResponse prepares and writes an error response i nJSON

func WriteJSONObject

func WriteJSONObject(ctx context.Context, w http.ResponseWriter, obj interface{})

WriteJSONObject simply writes object to the HTTP response in JSON format

Types

type Duration

type Duration struct {
	time.Duration
}

Duration is used strictly for JSON requests/responses due to duration marshalling issues

func (Duration) MarshalJSON

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

MarshalJSON marshals the duration

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the duration

type EmptyObject

type EmptyObject struct {
}

EmptyObject is an empty struct used to return empty JSON object

type ErrorResponse

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

Jump to

Keyboard shortcuts

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