Documentation
¶
Overview ¶
Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.
Index ¶
- func DTLSOptions(things domain.ThingsClient, logger log.Logger) []piondtls.ServerOption
- func DerivePSK(key string) []byte
- func LoggingMiddleware(svc coap.Service, logger log.Logger) coap.Service
- func MakeCoAPHandler(svc coap.Service, l log.Logger) mux.HandlerFunc
- func MakeHTTPHandler() http.Handler
- func MetricsMiddleware(svc coap.Service, counter metrics.Counter, latency metrics.Histogram) coap.Service
- func OnNewDTLSConn(things domain.ThingsClient, logger log.Logger) func(*udpclient.Conn)
- func PSK(things domain.ThingsClient, logger log.Logger) piondtls.PSKCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DTLSOptions ¶ added in v0.46.0
func DTLSOptions(things domain.ThingsClient, logger log.Logger) []piondtls.ServerOption
DTLSOptions returns the DTLS server options: PSK authentication, the cipher suites constrained devices support, and connection IDs, which keep a session alive when NAT changes the client's address (RFC 9146).
func DerivePSK ¶ added in v0.46.0
DerivePSK returns the pre-shared key of a thing: the first 32 hex characters of the SHA-256 hash of its key. The key itself is longer than constrained DTLS stacks accept, and hex keeps the PSK usable as a string in clients and device configs.
func LoggingMiddleware ¶
LoggingMiddleware adds logging facilities to the adapter.
func MakeCoAPHandler ¶
MakeCoAPHandler creates handler for CoAP messages.
func MakeHTTPHandler ¶
MakeHTTPHandler returns a HTTP handler for API endpoints.
func MetricsMiddleware ¶
func MetricsMiddleware(svc coap.Service, counter metrics.Counter, latency metrics.Histogram) coap.Service
MetricsMiddleware instruments adapter by tracking request count and latency.
func OnNewDTLSConn ¶ added in v0.46.0
OnNewDTLSConn stores the key of the thing that completed the handshake, so that requests on the connection need no auth query.
func PSK ¶ added in v0.46.0
func PSK(things domain.ThingsClient, logger log.Logger) piondtls.PSKCallback
PSK returns the DTLS PSK callback, which takes the thing ID as the PSK identity and DerivePSK of the thing key as the pre-shared key.
Types ¶
This section is empty.