problem

package
v0.5.12 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 3 Imported by: 0 modules, 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 problem defines the RFC 7807 problem+json error body shared by the Schedularr API's handlers (internal/api) and its HTTP middleware (internal/api/middleware).

It exists as its own leaf package -- depending on neither of those -- specifically to avoid an import cycle. internal/api/middleware needs to write a problem+json response and read the per-request id middleware.RequestID stashes in context; internal/api/router.go (which lives in package api, alongside every handler file) needs to import internal/api/middleware to assemble RequestID/Logging/Recovery/BearerAuth onto the router. Before router.go existed, middleware imported internal/api directly for exactly the two things this package now provides -- that was fine when nothing in internal/api imported internal/api/middleware back. Once router.go does, api -> middleware -> api would cycle. internal/api/problem.go re-exports everything here (Problem as a type alias, the rest as thin wrapper functions), so every existing caller in internal/api keeps compiling unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithRequestID

func ContextWithRequestID(ctx context.Context, id string) context.Context

ContextWithRequestID returns a copy of ctx carrying the given request ID. The request-ID middleware (internal/api/middleware.RequestID) calls this once per request.

func RequestIDFromContext

func RequestIDFromContext(ctx context.Context) string

RequestIDFromContext returns the request ID stored by ContextWithRequestID, or "" if none was set.

func WriteProblem

func WriteProblem(w http.ResponseWriter, r *http.Request, status int, title, detail string)

WriteProblem writes an RFC 7807 problem+json response. Type is set to "about:blank" since Schedularr does not publish per-error type URIs. RequestID is populated from the request context when the request-ID middleware has set one.

Types

type Problem

type Problem struct {
	Type      string `json:"type"`
	Title     string `json:"title"`
	Status    int    `json:"status"`
	Detail    string `json:"detail,omitempty"`
	RequestID string `json:"request_id,omitempty"`
}

Problem is an RFC 7807 problem+json error body.

Jump to

Keyboard shortcuts

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