coap

package
v1.9.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackend

func NewBackend() backends.Backend

NewBackend creates a new CoAP backend

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend implements the backends.Backend interface for CoAP

func (*Backend) GetMode

func (b *Backend) GetMode() string

GetMode returns the current mode

func (*Backend) Logger

func (b *Backend) Logger() backends.MiddlewareFunc

Logger returns a no-op middleware as CoAP handles logging differently

func (*Backend) NewEngine

func (b *Backend) NewEngine() backends.Engine

NewEngine panics as CoAP doesn't use the Engine pattern

func (*Backend) NewEngineWithDefaults

func (b *Backend) NewEngineWithDefaults() backends.Engine

NewEngineWithDefaults panics as CoAP doesn't use the Engine pattern

func (*Backend) NewServer

func (b *Backend) NewServer(port int, engine backends.Engine) backends.Server

NewServer creates a new CoAP server with the given port and handler The engine parameter is ignored for CoAP as it doesn't use the Engine pattern

func (*Backend) NewServerWithAddr

func (b *Backend) NewServerWithAddr(addr string, engine backends.Engine) backends.Server

NewServerWithAddr creates a new CoAP server with the given address

func (*Backend) NewServerWithAddrAndHandler

func (b *Backend) NewServerWithAddrAndHandler(addr string, handler RPCHandler) backends.Server

NewServerWithAddrAndHandler creates a new CoAP server with address and handler

func (*Backend) NewServerWithHandler

func (b *Backend) NewServerWithHandler(port int, handler RPCHandler) backends.Server

NewServerWithHandler creates a new CoAP server with an RPC handler

func (*Backend) Recovery

func (b *Backend) Recovery() backends.MiddlewareFunc

Recovery returns a no-op middleware as CoAP handles panics differently

func (*Backend) SetMode

func (b *Backend) SetMode(mode string)

SetMode sets the backend mode (release, debug, test)

type CoAPServer

type CoAPServer struct {
	// contains filtered or unexported fields
}

CoAPServer wraps a CoAP server to implement backends.Server interface

func NewCoAPServer

func NewCoAPServer(port int, handler RPCHandler) *CoAPServer

NewCoAPServer creates a new CoAP server wrapper

func NewCoAPServerWithAddr

func NewCoAPServerWithAddr(addr string, handler RPCHandler) *CoAPServer

NewCoAPServerWithAddr creates a new CoAP server with a specific address

func (*CoAPServer) Engine

func (s *CoAPServer) Engine() backends.Engine

Engine returns nil as CoAP doesn't use the Engine pattern

func (*CoAPServer) GetAddr

func (s *CoAPServer) GetAddr() string

GetAddr returns the server address

func (*CoAPServer) HTTPServer

func (s *CoAPServer) HTTPServer() *http.Server

HTTPServer returns nil as CoAP server is not an HTTP server

func (*CoAPServer) ListenAndServe

func (s *CoAPServer) ListenAndServe() error

ListenAndServe starts the CoAP server

func (*CoAPServer) ListenAndServeTLS

func (s *CoAPServer) ListenAndServeTLS(certFile, keyFile string) error

ListenAndServeTLS starts the CoAP server with DTLS (not implemented yet)

func (*CoAPServer) SetAddr

func (s *CoAPServer) SetAddr(addr string)

SetAddr sets the server address

func (*CoAPServer) SetHandler

func (s *CoAPServer) SetHandler(handler RPCHandler)

SetHandler sets the RPC handler (must be called before ListenAndServe)

func (*CoAPServer) SetIdleTimeout

func (s *CoAPServer) SetIdleTimeout(timeout time.Duration)

SetIdleTimeout is a no-op for CoAP

func (*CoAPServer) SetReadHeaderTimeout

func (s *CoAPServer) SetReadHeaderTimeout(timeout time.Duration)

SetReadHeaderTimeout is a no-op for CoAP

func (*CoAPServer) SetReadTimeout

func (s *CoAPServer) SetReadTimeout(timeout time.Duration)

SetReadTimeout is a no-op for CoAP (CoAP handles timeouts differently)

func (*CoAPServer) SetWriteTimeout

func (s *CoAPServer) SetWriteTimeout(timeout time.Duration)

SetWriteTimeout is a no-op for CoAP

func (*CoAPServer) Shutdown

func (s *CoAPServer) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the CoAP server

func (*CoAPServer) ShutdownWithTimeout

func (s *CoAPServer) ShutdownWithTimeout(timeout time.Duration) error

ShutdownWithTimeout shuts down with a timeout

type RPCHandler

type RPCHandler interface {
	HandleRPC(jsonPayload string) (string, error)
}

RPCHandler is an interface for handling RPC messages This is implemented by the Server struct which provides access to all business logic

Jump to

Keyboard shortcuts

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