http

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAuthContext

func GetAuthContext(ctx context.Context) *domain.AuthContext

GetAuthContext retrieves the auth context from request context

Types

type AdminStatsResponse

type AdminStatsResponse struct {
	Documents   DocumentStats   `json:"documents"`
	Chunks      ChunkStats      `json:"chunks"`
	Sources     SourceStats     `json:"sources"`
	Connections ConnectionStats `json:"installations"`
	Users       UserStats       `json:"users"`
}

AdminStatsResponse represents system-wide statistics @Description System-wide statistics for the admin dashboard

type AuthMiddleware

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

AuthMiddleware handles authentication and authorization

func NewAuthMiddleware

func NewAuthMiddleware(authService driving.AuthService) *AuthMiddleware

NewAuthMiddleware creates a new AuthMiddleware

func (*AuthMiddleware) Authenticate

func (m *AuthMiddleware) Authenticate(next http.Handler) http.Handler

Authenticate validates the request token and adds auth context

func (*AuthMiddleware) RequireAdmin

func (m *AuthMiddleware) RequireAdmin(next http.Handler) http.Handler

RequireAdmin ensures the authenticated user is an admin

func (*AuthMiddleware) RequireRole

func (m *AuthMiddleware) RequireRole(roles ...domain.Role) func(http.Handler) http.Handler

RequireRole ensures the authenticated user has one of the specified roles

type CORSMiddleware

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

CORSMiddleware handles CORS

func NewCORSMiddleware

func NewCORSMiddleware(allowedOrigins []string) *CORSMiddleware

NewCORSMiddleware creates a new CORSMiddleware

func (*CORSMiddleware) Handler

func (m *CORSMiddleware) Handler(next http.Handler) http.Handler

Handler wraps an http.Handler with CORS headers

type ChunkStats

type ChunkStats struct {
	Total int `json:"total"`
}

ChunkStats represents chunk statistics

type ComponentHealth

type ComponentHealth struct {
	Status  string `json:"status"`            // "healthy" or "unhealthy"
	Message string `json:"message,omitempty"` // optional message for unhealthy components
}

ComponentHealth represents health status of a single component

type Config

type Config struct {
	Host        string
	Port        int
	Version     string
	CORSOrigins []string
	UIBaseURL   string // Frontend URL for OAuth redirects (default: http://localhost:3000)
}

Config holds server configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults

type ConnectionStats

type ConnectionStats struct {
	Total int `json:"total"`
}

ConnectionStats represents installation statistics

type DocumentStats

type DocumentStats struct {
	Total int `json:"total"`
}

DocumentStats represents document statistics

type DocumentURLResponse

type DocumentURLResponse struct {
	URL string `json:"url" example:"https://github.com/owner/repo/blob/main/README.md"`
}

DocumentURLResponse represents the response containing a document's external URL @Description Document URL response

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error" example:"invalid request body"`
}

ErrorResponse represents an API error response @Description API error response

type HealthResponse

type HealthResponse struct {
	Status     string                     `json:"status"`               // overall status: "healthy" or "degraded"
	Components map[string]ComponentHealth `json:"components,omitempty"` // individual component health
}

HealthResponse represents the health check response with component status

type LoggingMiddleware

type LoggingMiddleware struct{}

LoggingMiddleware logs HTTP requests

func NewLoggingMiddleware

func NewLoggingMiddleware() *LoggingMiddleware

NewLoggingMiddleware creates a new LoggingMiddleware

func (*LoggingMiddleware) Handler

func (m *LoggingMiddleware) Handler(next http.Handler) http.Handler

Handler wraps an http.Handler with request logging

type Pinger

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

Pinger is a simple health check interface

type RecoveryMiddleware

type RecoveryMiddleware struct{}

RecoveryMiddleware recovers from panics

func NewRecoveryMiddleware

func NewRecoveryMiddleware() *RecoveryMiddleware

NewRecoveryMiddleware creates a new RecoveryMiddleware

func (*RecoveryMiddleware) Handler

func (m *RecoveryMiddleware) Handler(next http.Handler) http.Handler

Handler wraps an http.Handler with panic recovery

type ResetPasswordRequest

type ResetPasswordRequest struct {
	Password string `json:"password" binding:"required"`
}

ResetPasswordRequest represents a password reset request @Description Password reset request

type Server

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

Server represents the HTTP server

func NewServer

func NewServer(
	cfg Config,
	authService driving.AuthService,
	userService driving.UserService,
	searchService driving.SearchService,
	sourceService driving.SourceService,
	docService driving.DocumentService,
	settingsService driving.SettingsService,
	providerService driving.ProviderService,
	oauthService driving.OAuthService,
	connectionService driving.ConnectionService,
	syncOrchestrator driving.SyncOrchestrator,
	capabilitiesService driving.CapabilitiesService,
	setupService driving.SetupService,
	adminService driving.AdminService,
	taskQueue driven.TaskQueue,
	searchQueryRepo driven.SearchQueryRepository,
	db Pinger,
	redisClient Pinger,
	oauthServerService driving.OAuthServerService,
	mcpHandler http.Handler,
) *Server

NewServer creates a new HTTP server

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP server with graceful shutdown

func (*Server) Stop

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

Stop stops the server

type SourceDocumentsResponse

type SourceDocumentsResponse struct {
	Documents []*domain.Document `json:"documents"`
	Total     int                `json:"total"`
	Limit     int                `json:"limit"`
	Offset    int                `json:"offset"`
}

SourceDocumentsResponse represents a paginated list of documents for a source @Description Paginated list of documents belonging to a source

type SourceStats

type SourceStats struct {
	Total   int `json:"total"`
	Enabled int `json:"enabled"`
}

SourceStats represents source statistics

type StatusResponse

type StatusResponse struct {
	Status string `json:"status" example:"ok"`
}

StatusResponse represents a simple status response @Description Simple status response

type SyncAcceptedResponse

type SyncAcceptedResponse struct {
	Status   string `json:"status" example:"accepted"`
	SourceID string `json:"source_id" example:"src_abc123"`
}

SyncAcceptedResponse represents the response when sync is triggered @Description Sync accepted response

type TriggerReindexResponse

type TriggerReindexResponse struct {
	TaskIDs []string `json:"task_ids"`
	Message string   `json:"message"`
}

TriggerReindexResponse represents the response from triggering a reindex @Description Response containing task IDs created for reindex operation

type UpdateContainersRequest

type UpdateContainersRequest struct {
	// Containers is the list of containers to index.
	// Empty list means index all available containers.
	Containers []domain.Container `json:"containers"`
}

UpdateContainersRequest represents a request to update source container containers @Description Request to update which containers a source should index

type UserStats

type UserStats struct {
	Total int `json:"total"`
}

UserStats represents user statistics

type VersionResponse

type VersionResponse struct {
	Version string `json:"version" example:"1.0.0"`
}

VersionResponse represents the API version response @Description API version response

Jump to

Keyboard shortcuts

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