utils

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoValToProtoStruct

func GoValToProtoStruct(v interface{}) (*structpb.Value, error)

func ProtoStructToGoVal

func ProtoStructToGoVal(v *structpb.Value, into interface{}) error

func ReadJSON

func ReadJSON(r *http.Request, into any) error

func WriteErr

func WriteErr(w http.ResponseWriter, err error)

WriteErr interprets the given error as one of the errors defined in errors package and writes the error response.

func WriteErrMsg added in v0.7.9

func WriteErrMsg(w http.ResponseWriter, statusCode int, message string)

WriteErr interprets the given error as one of the errors defined in errors package and writes the error response.

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v interface{})

WriteJSON writes 'v' to response-writer in JSON format.

Types

type ListResponse

type ListResponse[T any] struct {
	Items []T `json:"items"`
}

ListResponse can be used to write list of items to response. This format is helpful in enabling pagination.

Jump to

Keyboard shortcuts

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