api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package api hosts the HTTP routing layer: a chi router that exposes /api/v1/scan (POST + GET by id) and /api/v1/checks, wired with request-ID, slog request logger, panic recovery and per-IP rate limiting. All inbound JSON shapes and error codes follow

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRouter

func NewRouter(d Deps) *chi.Mux

NewRouter returns a chi.Mux mounting the API and its middleware stack. The caller embeds it in their http.Server.

Types

type Deps

type Deps struct {
	Scanner ScanService
	Config  *config.Config
	Logger  *slog.Logger
}

Deps groups the runtime dependencies used to build a router.

type ScanService

type ScanService interface {
	Run(ctx context.Context, req scanner.Request) (*scan.Result, error)
	Get(id string) (*scan.Result, bool)
	History(limit int) []history.Entry
}

ScanService is the subset of scanner.Scanner the API depends on. scanner.Scanner satisfies this interface; tests inject a fake to bypass the real DNS + probe pipeline.

Jump to

Keyboard shortcuts

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