api

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PathParameterJobID is the name of the job ID path parameter.
	PathParameterJobID = "job_id"

	// QueryParameterLimit is the name of the limit query parameter.
	QueryParameterLimit = "limit"
	// QueryParameterOffset is the name of the offset query parameter.
	QueryParameterOffset = "offset"
)

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
}

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

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

Jump to

Keyboard shortcuts

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