package responsewriter

import "github.com/plgd-dev/go-coap/v3/net/responsewriter"

Index

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

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

Swap message in response without releasing.

Source Files

responseWriter.go

Version
v3.3.6 (latest)
Published
Sep 18, 2024
Platform
linux/amd64
Imports
5 packages
Last checked
1 week ago

Tools for package owners.