restutil

package
v0.0.0-...-432d548 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MimePB is Mime type protobuf
	MimePB = "application/x-protobuf"
)

Variables

This section is empty.

Functions

func NewEntityAccessorPB

func NewEntityAccessorPB(contentType string) restful.EntityReaderWriter

NewEntityAccessorPB returns a new EntityReaderWriter for accessing PB content.

func PatchContainer

func PatchContainer(container *restful.Container, opts *PatchContainerOptions)

PatchContainer patch the container

Types

type Entity

type Entity interface {
	HasError() bool
}

Entity represents response result.

type EntityHandler

type EntityHandler func(request *restful.Request, response *restful.Response) Entity

EntityHandler entity handler to process requests.

type EntityRoute

type EntityRoute struct {
	// Record the entity encoding time
	EncodeTimeFunc RecordTimeFunc
	// Usually to report panic metric
	RecoverRecorder func(reason interface{}, request *restful.Request)
	// logging
	LoggingFunc RecordTimeFunc
	// Record io write time
	WriteTimeFunc RecordTimeFunc
	// Called if got error entity
	ErrorFunc func(request *restful.Request, response *restful.Response, e Entity)
}

EntityRoute generates handler to restful service.

func (*EntityRoute) To

func (r *EntityRoute) To(h EntityHandler) restful.RouteFunction

To returns handler

type PatchContainerOptions

type PatchContainerOptions struct {
	// Global logging
	LoggingFunc RecordTimeFunc
}

PatchContainerOptions options to patch container

type RecordTimeFunc

type RecordTimeFunc func(request *restful.Request, response *restful.Response, latency time.Duration)

RecordTimeFunc function to record latency time

Jump to

Keyboard shortcuts

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