responsewriter

package
v3.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 2 modules, 1 package

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 AfterWrite added in v3.7.0

func AfterWrite(ctx context.Context, callback func()) bool

AfterWrite registers callback to run after the response is written. It returns false when ctx was not created by WithPostWriteCallbacks.

func WithPostWriteCallbacks added in v3.7.0

func WithPostWriteCallbacks(ctx context.Context) (context.Context, func())

WithPostWriteCallbacks returns a context that supports callbacks after the response has been written, and a function to run those callbacks.

Types

type Client

type Client interface {
	ReleaseMessage(msg *pool.Message)
}

type ResponseWriter

type ResponseWriter[C Client] struct {
	// contains filtered or unexported fields
}

A ResponseWriter is used by an COAP handler to construct an COAP response.

func New

func New[C Client](response *pool.Message, cc C, requestOptions ...message.Option) *ResponseWriter[C]

func (*ResponseWriter[C]) Conn

func (r *ResponseWriter[C]) Conn() C

CConn peer connection.

func (*ResponseWriter[C]) Message

func (r *ResponseWriter[C]) Message() *pool.Message

Message direct access to the response.

func (*ResponseWriter[C]) SetMessage

func (r *ResponseWriter[C]) SetMessage(m *pool.Message)

SetMessage replaces the response message. The original message was released to the message pool, so don't use it any more. Ensure that Token, MessageID(udp), and Type(udp) messages are paired correctly.

func (*ResponseWriter[C]) SetResponse

func (r *ResponseWriter[C]) SetResponse(code codes.Code, contentFormat message.MediaType, d io.ReadSeeker, opts ...message.Option) error

SetResponse simplifies the setup of the response for the request. ETags must be set via options. For advanced setup, use Message().

func (*ResponseWriter[C]) Swap added in v3.1.1

func (r *ResponseWriter[C]) Swap(m *pool.Message) *pool.Message

Swap message in response without releasing.

Jump to

Keyboard shortcuts

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