httpsrv

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package httpsrv hosts the bot's HTTP listener: a read-only manifest viewer, a health endpoint, and (in follow-up commits) the slash-command handler plus signed approval URLs.

The package name avoids collision with the stdlib net/http import that callers also need.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignApprovalToken

func SignApprovalToken(key, manifestID string) string

SignApprovalToken returns the HMAC-SHA256 token (URL-safe base64) that proves the holder is authorised to apply the named manifest. Exported so the bot can build approve URLs before sending them to chat.

Types

type Options

type Options struct {
	SigningKey string
	Connector  cleanup.Connector
	Audit      *audit.Logger
	BaseURL    string
	// Metrics, when non-nil, enables the /metrics endpoint and records
	// approval-apply outcomes and latency. May be nil.
	Metrics *metrics.Metrics
}

Options groups optional Server inputs that have grown beyond a sensible positional argument list. SigningKey and Connector are optional; supplying neither restricts the listener to the read-only endpoints (/health and /manifest/:id). Audit may be nil; the audit logger already treats a nil receiver as a no-op. BaseURL is the public URL the bot prints into chat replies (e.g. `https://natsie.example.com`); only used by the on-demand scan chat command.

type Server

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

Server wraps an Echo instance with the bot-specific dependencies it needs (manifest store, signing key, NATS connector, audit log, logger).

func New

func New(listen string, st store.Store, opts Options, logger *log.Logger) *Server

New constructs the Server. Routes are registered immediately so callers can list them in startup logs. SigningKey gates the /slash and /approve endpoints; Connector additionally gates /approve (we don't expose the deletion path without a way to actually delete).

func (*Server) SignApproval

func (s *Server) SignApproval(manifestID string) string

SignApproval returns the HMAC-SHA256 token (base64url) that authorises the approval URL for the given manifest ID. Exported so the bot can build the link before sending it to chat.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start launches the HTTP listener and blocks until ctx is canceled. StartConfig.Start handles the graceful shutdown internally.

Jump to

Keyboard shortcuts

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