utils

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 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 added in v0.2.1

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

func ProtoStructToGoVal added in v0.2.1

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

func ReadJSON added in v0.2.1

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 WriteJSON

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

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

Types

type ListResponse added in v0.2.1

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