server

package
v0.0.0-...-3c63c23 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package server provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.5.1 DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func Handler

func Handler(si ServerInterface) http.Handler

Handler creates http.Handler with routing matching OpenAPI spec.

func HandlerFromMux

func HandlerFromMux(si ServerInterface, m ServeMux) http.Handler

HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.

func HandlerFromMuxWithBaseURL

func HandlerFromMuxWithBaseURL(si ServerInterface, m ServeMux, baseURL string) http.Handler

func HandlerWithOptions

func HandlerWithOptions(si ServerInterface, options StdHTTPServerOptions) http.Handler

HandlerWithOptions creates http.Handler with additional options

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func SPAHandler

func SPAHandler(fsys fs.FS) http.Handler

SPAHandler serves static files from the given filesystem, falling back to index.html for client-side routing.

Types

type ErrorResponse

type ErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

ErrorResponse defines model for ErrorResponse.

type GetHealth200JSONResponse

type GetHealth200JSONResponse HealthResponse

func (GetHealth200JSONResponse) VisitGetHealthResponse

func (response GetHealth200JSONResponse) VisitGetHealthResponse(w http.ResponseWriter) error

type GetHealthRequestObject

type GetHealthRequestObject struct {
}

type GetHealthResponseObject

type GetHealthResponseObject interface {
	VisitGetHealthResponse(w http.ResponseWriter) error
}

type GetRun200JSONResponse

type GetRun200JSONResponse Run

func (GetRun200JSONResponse) VisitGetRunResponse

func (response GetRun200JSONResponse) VisitGetRunResponse(w http.ResponseWriter) error

type GetRun404JSONResponse

type GetRun404JSONResponse ErrorResponse

func (GetRun404JSONResponse) VisitGetRunResponse

func (response GetRun404JSONResponse) VisitGetRunResponse(w http.ResponseWriter) error

type GetRunRequestObject

type GetRunRequestObject struct {
	Id string `json:"id"`
}

type GetRunResponseObject

type GetRunResponseObject interface {
	VisitGetRunResponse(w http.ResponseWriter) error
}

type Handlers

type Handlers struct {
	Version   string
	StartTime time.Time
	Logger    *slog.Logger
	MultiRepo bool // when true, aggregate runs from all registered repos
}

Handlers implements the generated StrictServerInterface.

func (*Handlers) GetRun

func (*Handlers) ListRuns

type HealthResponse

type HealthResponse struct {
	Status        string `json:"status"`
	UptimeSeconds int    `json:"uptime_seconds"`
	Version       string `json:"version"`
}

HealthResponse defines model for HealthResponse.

type InvalidParamFormatError

type InvalidParamFormatError struct {
	ParamName string
	Err       error
}

func (*InvalidParamFormatError) Error

func (e *InvalidParamFormatError) Error() string

func (*InvalidParamFormatError) Unwrap

func (e *InvalidParamFormatError) Unwrap() error

type ListRuns200JSONResponse

type ListRuns200JSONResponse RunList

func (ListRuns200JSONResponse) VisitListRunsResponse

func (response ListRuns200JSONResponse) VisitListRunsResponse(w http.ResponseWriter) error

type ListRunsParams

type ListRunsParams struct {
	Status *RunStatus `form:"status,omitempty" json:"status,omitempty"`
	Limit  *int       `form:"limit,omitempty" json:"limit,omitempty"`
	Offset *int       `form:"offset,omitempty" json:"offset,omitempty"`
}

ListRunsParams defines parameters for ListRuns.

type ListRunsRequestObject

type ListRunsRequestObject struct {
	Params ListRunsParams
}

type ListRunsResponseObject

type ListRunsResponseObject interface {
	VisitListRunsResponse(w http.ResponseWriter) error
}

type MiddlewareFunc

type MiddlewareFunc func(http.Handler) http.Handler

type RequiredHeaderError

type RequiredHeaderError struct {
	ParamName string
	Err       error
}

func (*RequiredHeaderError) Error

func (e *RequiredHeaderError) Error() string

func (*RequiredHeaderError) Unwrap

func (e *RequiredHeaderError) Unwrap() error

type RequiredParamError

type RequiredParamError struct {
	ParamName string
}

func (*RequiredParamError) Error

func (e *RequiredParamError) Error() string

type Run

type Run struct {
	Branch       *string     `json:"branch,omitempty"`
	CrFeedback   *string     `json:"cr_feedback,omitempty"`
	CrFixSummary *string     `json:"cr_fix_summary,omitempty"`
	CreatedAt    time.Time   `json:"created_at"`
	Id           string      `json:"id"`
	IssueKey     *string     `json:"issue_key,omitempty"`
	IssueUrl     *string     `json:"issue_url,omitempty"`
	Mode         *string     `json:"mode,omitempty"`
	PlanPath     string      `json:"plan_path"`
	PlanTitle    *string     `json:"plan_title,omitempty"`
	PrNumber     *int        `json:"pr_number,omitempty"`
	PrUrl        *string     `json:"pr_url,omitempty"`
	SourceIssue  *int        `json:"source_issue,omitempty"`
	Status       RunStatus   `json:"status"`
	Steps        []StepState `json:"steps"`
	UpdatedAt    time.Time   `json:"updated_at"`
	WorktreePath *string     `json:"worktree_path,omitempty"`
}

Run defines model for Run.

type RunList

type RunList struct {
	Runs  []Run `json:"runs"`
	Total int   `json:"total"`
}

RunList defines model for RunList.

type RunStatus

type RunStatus string

RunStatus defines model for RunStatus.

const (
	RunStatusActive    RunStatus = "active"
	RunStatusCompleted RunStatus = "completed"
	RunStatusFailed    RunStatus = "failed"
)

Defines values for RunStatus.

type SSEHub

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

SSEHub fans out run-state change events to connected SSE clients.

func NewSSEHub

func NewSSEHub(runsDir string, logger *slog.Logger) *SSEHub

NewSSEHub creates an SSEHub watching the given runs directory.

func (*SSEHub) ServeHTTP

func (h *SSEHub) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler for SSE connections.

func (*SSEHub) Start

func (h *SSEHub) Start(ctx context.Context)

Start watches runsDir for file changes and broadcasts events. Blocks until ctx is cancelled.

type ServeMux

type ServeMux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

ServeMux is an abstraction of http.ServeMux.

type Server

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

Server is the forge dashboard HTTP server.

func New

func New(port int, runsDir, version string, logger *slog.Logger) *Server

New creates a Server with the given options.

func (*Server) RegisterLogStream

func (s *Server) RegisterLogStream(mux *http.ServeMux)

RegisterLogStream adds the log streaming endpoint to the given mux.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the HTTP server and blocks until ctx is cancelled.

func (*Server) SetMultiRepo

func (s *Server) SetMultiRepo(enabled bool)

SetMultiRepo enables aggregation of runs from all registered repos.

type ServerInterface

type ServerInterface interface {
	// Health check
	// (GET /health)
	GetHealth(w http.ResponseWriter, r *http.Request)
	// List pipeline runs
	// (GET /runs)
	ListRuns(w http.ResponseWriter, r *http.Request, params ListRunsParams)
	// Get run detail
	// (GET /runs/{id})
	GetRun(w http.ResponseWriter, r *http.Request, id string)
}

ServerInterface represents all server handlers.

func NewStrictHandler

func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface

func NewStrictHandlerWithOptions

func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler            ServerInterface
	HandlerMiddlewares []MiddlewareFunc
	ErrorHandlerFunc   func(w http.ResponseWriter, r *http.Request, err error)
}

ServerInterfaceWrapper converts contexts to parameters.

func (*ServerInterfaceWrapper) GetHealth

func (siw *ServerInterfaceWrapper) GetHealth(w http.ResponseWriter, r *http.Request)

GetHealth operation middleware

func (*ServerInterfaceWrapper) GetRun

GetRun operation middleware

func (*ServerInterfaceWrapper) ListRuns

func (siw *ServerInterfaceWrapper) ListRuns(w http.ResponseWriter, r *http.Request)

ListRuns operation middleware

type StdHTTPServerOptions

type StdHTTPServerOptions struct {
	BaseURL          string
	BaseRouter       ServeMux
	Middlewares      []MiddlewareFunc
	ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StepState

type StepState struct {
	Error  *string    `json:"error,omitempty"`
	Name   string     `json:"name"`
	Status StepStatus `json:"status"`
}

StepState defines model for StepState.

type StepStatus

type StepStatus string

StepStatus defines model for StepStatus.

const (
	StepStatusCompleted StepStatus = "completed"
	StepStatusFailed    StepStatus = "failed"
	StepStatusPending   StepStatus = "pending"
	StepStatusRunning   StepStatus = "running"
)

Defines values for StepStatus.

type StrictHTTPServerOptions

type StrictHTTPServerOptions struct {
	RequestErrorHandlerFunc  func(w http.ResponseWriter, r *http.Request, err error)
	ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error)
}

type StrictServerInterface

type StrictServerInterface interface {
	// Health check
	// (GET /health)
	GetHealth(ctx context.Context, request GetHealthRequestObject) (GetHealthResponseObject, error)
	// List pipeline runs
	// (GET /runs)
	ListRuns(ctx context.Context, request ListRunsRequestObject) (ListRunsResponseObject, error)
	// Get run detail
	// (GET /runs/{id})
	GetRun(ctx context.Context, request GetRunRequestObject) (GetRunResponseObject, error)
}

StrictServerInterface represents all server handlers.

type TooManyValuesForParamError

type TooManyValuesForParamError struct {
	ParamName string
	Count     int
}

func (*TooManyValuesForParamError) Error

type UnescapedCookieParamError

type UnescapedCookieParamError struct {
	ParamName string
	Err       error
}

func (*UnescapedCookieParamError) Error

func (e *UnescapedCookieParamError) Error() string

func (*UnescapedCookieParamError) Unwrap

func (e *UnescapedCookieParamError) Unwrap() error

type UnmarshalingParamError

type UnmarshalingParamError struct {
	ParamName string
	Err       error
}

func (*UnmarshalingParamError) Error

func (e *UnmarshalingParamError) Error() string

func (*UnmarshalingParamError) Unwrap

func (e *UnmarshalingParamError) Unwrap() error

Jump to

Keyboard shortcuts

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