api

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PathParameterJobNumber is the name of the job number path parameter.
	PathParameterJobNumber = "job_number"
	// QueryParameterLimit is the name of the limit query parameter.
	QueryParameterLimit = "limit"
	// QueryParameterOffset is the name of the offset query parameter.
	QueryParameterOffset = "offset"
	// QueryParameterSort is the name of the sort query parameter.
	QueryParameterSort = "sort"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MigrationAPI added in v0.4.0

type MigrationAPI struct {
	JobService     application.JobService
	Migrator       migrator.Migrator
	Paginator      *Paginator
	Router         *mux.Router
	AuthMiddleware auth.Middleware
}

MigrationAPI provides a struct to wrap the api around

func Setup

func Setup(_ context.Context, cfg *config.Config, router *mux.Router, jobService application.JobService, authMiddleware auth.Middleware) *MigrationAPI

Setup function sets up the api and returns an api context has been blanked here for now in anticipation of future use

func (*MigrationAPI) GetUserID added in v0.25.0

func (api *MigrationAPI) GetUserID(r *http.Request) (string, error)

GetUserID extracts the user ID from the Authorization header by parsing the JWT token. Returns the user ID or an empty string if the token cannot be parsed.

type PaginatedHandler added in v0.10.0

type PaginatedHandler func(w http.ResponseWriter, r *http.Request, limit int, offset int) (items interface{}, totalCount int, err error)

PaginatedHandler defines a handler function signature for paginated endpoints

type PaginatedResponse added in v0.10.0

type PaginatedResponse struct {
	Items            interface{} `json:"items"`
	PaginationFields             // embedded, flattening fields into JSON
}

PaginatedResponse represents a paginated API response

type PaginationFields added in v0.10.0

type PaginationFields struct {
	Count      int `json:"count"`
	Limit      int `json:"limit"`
	Offset     int `json:"offset"`
	TotalCount int `json:"total_count"`
}

PaginationFields represents the generic fields used to describe pagination in an API response

type Paginator added in v0.10.0

type Paginator struct {
	DefaultLimit    int
	DefaultOffset   int
	DefaultMaxLimit int
}

Paginator handles pagination logic for API endpoints

func NewPaginator added in v0.10.0

func NewPaginator(defaultLimit, defaultOffset, defaultMaxLimit int) *Paginator

NewPaginator creates a new Paginator with specified default values

func (*Paginator) Paginate added in v0.10.0

func (p *Paginator) Paginate(paginatedHandler PaginatedHandler) func(w http.ResponseWriter, r *http.Request)

Paginate is a middleware function that handles pagination for API endpoints

type StateChangeRequest added in v0.20.0

type StateChangeRequest struct {
	State domain.State `json:"state"`
}

StateChangeRequest represents the payload used to request a job state change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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