api

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 26 Imported by: 1 module, 0 packages

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

Overview

Package api contains API-related concerns: endpoint definitions, middlewares and all resource representations.

Index

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

func DerivePSK(key string) []byte

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

func LoggingMiddleware(svc coap.Service, logger log.Logger) coap.Service

LoggingMiddleware adds logging facilities to the adapter.

func MakeCoAPHandler

func MakeCoAPHandler(svc coap.Service, l log.Logger) mux.HandlerFunc

MakeCoAPHandler creates handler for CoAP messages.

func MakeHTTPHandler

func MakeHTTPHandler() http.Handler

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

func OnNewDTLSConn(things domain.ThingsClient, logger log.Logger) func(*udpclient.Conn)

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.

Jump to

Keyboard shortcuts

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