mapsauth

package
v0.13.3 Latest Latest
Warning

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

Go to latest
Published: May 9, 2026 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package mapsauth is a thin client for auth.nw5w.com, the registration endpoint that issues per-device tokens for the Graywolf private map service. The package exists so handlers in pkg/webapi don't have to hand-roll JSON+timeout+error-mapping code, and so tests can swap in an httptest.Server via the BaseURL constructor argument.

Index

Constants

View Source
const DefaultBaseURL = "https://auth.nw5w.com"

DefaultBaseURL is the production registration endpoint. Override via NewClient when stubbing in tests.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the registration client. Construct via NewClient.

func NewClient

func NewClient(baseURL string) *Client

NewClient returns a client pointed at baseURL. Pass DefaultBaseURL in production. The HTTP client has a 15-second total timeout — the auth worker is fast under normal load, and a slow server is more likely a routing problem than a real deferred response.

func (*Client) Register

func (c *Client) Register(ctx context.Context, callsign string) (RegisterResponse, error)

Register POSTs the callsign to /register and returns the issued token on success. callsign should already be uppercased and have any -SSID stripped; the server will reject anything that doesn't match ^[A-Z0-9]{3,9}$ with a digit.

type Error

type Error struct {
	Status  int    `json:"-"`
	Code    string `json:"error"`
	Message string `json:"message"`
}

Error wraps a non-2xx response from the auth server. Status holds the HTTP status; Code is the machine-readable error name from the response body (or a synthesized value for empty-body cases like 429); Message is the human-readable string the server returned and is intended to be surfaced to the user verbatim — it points them at https://github.com/chrissnell/graywolf/issues.

func (*Error) Error

func (e *Error) Error() string

type RegisterResponse

type RegisterResponse struct {
	Callsign string `json:"callsign"`
	Token    string `json:"token"`
}

RegisterResponse is the success body emitted by POST /register.

Jump to

Keyboard shortcuts

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