httpserver

package
v0.0.0-...-1ea1845 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Header names, not credentials.
	HeaderMetadataToken = "X-Metadata-Token" //nolint:gosec
	HeaderBlobToken     = "X-Blob-Token"     //nolint:gosec
	HeaderDeletionToken = "X-Deletion-Token" //nolint:gosec

)
View Source
const (
	HeaderPartOffset = "X-Part-Offset"
	HeaderPartSize   = "X-Part-Size"
	HeaderPartSHA256 = "X-Part-SHA256"
)

Variables

This section is empty.

Functions

func Liveness

func Liveness(c *echo.Context) error

func ReadinessWithDB

func ReadinessWithDB(pinger Pinger) echo.HandlerFunc

func VersionHandler

func VersionHandler(version string) echo.HandlerFunc

VersionHandler reports the commit the running binary was built from, so the page can show which build is live.

Types

type App

type App struct {
	SecretMetrics *metrics.SecretMetrics
	// contains filtered or unexported fields
}

func New

func New(cfg config.Config, version string, pool *pgxpool.Pool, secretRepo domain.Repo, fileStore domain.MultipartFileStore, transferEvents TransferEvents, reg *prometheus.Registry) (*App, error)

New builds the app. transferEvents may be nil; transfer long-polls then poll the database.

func (*App) Shutdown

func (a *App) Shutdown(ctx context.Context) error

func (*App) Start

func (a *App) Start() error

Start serves until Shutdown, then returns http.ErrServerClosed.

type Pinger

type Pinger interface {
	Ping(ctx context.Context) error
}

type SecretHandler

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

SecretHandler serves everything a client does with an existing secret: metadata, retrieval sessions, range reads and deletion. Secrets are created through UploadHandler's multipart upload sessions.

func NewSecretHandler

func NewSecretHandler(repo domain.SecretRepo, fileStore domain.FileStore) *SecretHandler

func (*SecretHandler) DeleteSecret

func (h *SecretHandler) DeleteSecret(c *echo.Context) error

func (*SecretHandler) RetrieveSecretRange

func (h *SecretHandler) RetrieveSecretRange(c *echo.Context) error

func (*SecretHandler) SecretMetadata

func (h *SecretHandler) SecretMetadata(c *echo.Context) error

func (*SecretHandler) StartRetrievalSession

func (h *SecretHandler) StartRetrievalSession(c *echo.Context) error

type TransferEvents

type TransferEvents interface {
	// Subscribe returns a channel that is signalled whenever the transfer
	// changes, and a function that ends the subscription.
	Subscribe(transferID string) (<-chan struct{}, func())
}

TransferEvents wakes long-polls when a transfer changes on any replica.

type TransferHandler

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

TransferHandler relays short-code transfers in three legs: the sender creates the transfer with its PAKE share (the offer), the receiver claims it by nameplate and answers with its share and a confirmation tag, and the sender delivers the sealed link. Each leg is written once with POST and waited for with a GET long-poll. The server never sees the code or the link.

func NewTransferHandler

func NewTransferHandler(repo domain.TransferRepo, events TransferEvents) *TransferHandler

NewTransferHandler relays through repo. Without events, long-polls only notice changes when they re-check.

func (*TransferHandler) AwaitAnswer

func (h *TransferHandler) AwaitAnswer(c *echo.Context) error

AwaitAnswer long-polls for the receiver's answer.

func (*TransferHandler) AwaitDelivery

func (h *TransferHandler) AwaitDelivery(c *echo.Context) error

AwaitDelivery long-polls for the sealed link. It is returned even though storing it closed the transfer.

func (*TransferHandler) ClaimTransfer

func (h *TransferHandler) ClaimTransfer(c *echo.Context) error

ClaimTransfer joins the transfer under a nameplate and returns the offer the receiver answers.

func (*TransferHandler) CloseTransfer

func (h *TransferHandler) CloseTransfer(c *echo.Context) error

CloseTransfer ends a transfer early, as cancelled or as a mismatch. The delivery closes a successful one by itself.

func (*TransferHandler) CreateTransfer

func (h *TransferHandler) CreateTransfer(c *echo.Context) error

CreateTransfer opens a transfer with the sender's offer. The sender picks the transfer id, because its PAKE share depends on it.

func (*TransferHandler) PostAnswer

func (h *TransferHandler) PostAnswer(c *echo.Context) error

PostAnswer stores the receiver's PAKE share and confirmation tag. An identical retry succeeds; a different answer is refused.

func (*TransferHandler) PostDelivery

func (h *TransferHandler) PostDelivery(c *echo.Context) error

PostDelivery stores the sealed link once the transfer is answered, which closes it as done. An identical retry succeeds.

type UploadHandler

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

func NewUploadHandler

func NewUploadHandler(repo domain.UploadRepo, fileStore domain.MultipartFileStore, maxFileSize int64, m *metrics.SecretMetrics) *UploadHandler

func (*UploadHandler) AbortUploadSession

func (h *UploadHandler) AbortUploadSession(c *echo.Context) error

func (*UploadHandler) CompleteUploadSession

func (h *UploadHandler) CompleteUploadSession(c *echo.Context) error

func (*UploadHandler) CreateUploadSession

func (h *UploadHandler) CreateUploadSession(c *echo.Context) error

func (*UploadHandler) UploadPart

func (h *UploadHandler) UploadPart(c *echo.Context) error

Jump to

Keyboard shortcuts

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