Documentation
¶
Overview ¶
handlers/generic.go
Index ¶
- func Handle[T any, R any](handlerFunc HandlerFunc[T, R], opts HandlerOptions) http.HandlerFunc
- type CacheStats
- type DeleteObjectRequest
- type ErrorResponse
- type GetObjectRequest
- type GetObjectResponse
- type HandlerFunc
- type HandlerOptions
- type HeadObjectRequest
- type HealthHandler
- type NotFoundError
- type ObjectHandler
- type ObjectResponse
- type PutObjectRequest
- type Request
- type Response
- type StatsHandler
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handle ¶
func Handle[T any, R any](handlerFunc HandlerFunc[T, R], opts HandlerOptions) http.HandlerFunc
Handle creates a generic HTTP handler that processes requests of type T and returns responses of type R
Types ¶
type CacheStats ¶
type CacheStats struct { Hits uint64 `json:"hits"` Misses uint64 `json:"misses"` CurrentSize int64 `json:"current_size_bytes"` MaxSize int64 `json:"max_size_bytes"` EntryCount int `json:"entry_count"` LastCleanupTime time.Time `json:"last_cleanup_time"` TotalRequests uint64 `json:"total_requests"` CacheHitRatio float64 `json:"cache_hit_ratio"` AvgResponseTime float64 `json:"avg_response_time_ms"` CompressionRatio float64 `json:"compression_ratio"` }
type DeleteObjectRequest ¶
type DeleteObjectRequest struct{}
type ErrorResponse ¶
type ErrorResponse struct { Error string `json:"error"` Code int `json:"code"` Message string `json:"message"` }
ErrorResponse represents a standard error response
type GetObjectRequest ¶
type GetObjectRequest struct {
AcceptGzip bool
}
Object request/response types
type GetObjectResponse ¶
type HandlerFunc ¶
HandlerFunc is the generic handler function type
type HandlerOptions ¶
type HandlerOptions struct { Logger *slog.Logger DecodeBody bool ValidateInput func(interface{}) error }
HandlerOptions contains configuration for the handler
type HeadObjectRequest ¶
type HeadObjectRequest struct{}
type HealthHandler ¶
type HealthHandler struct {
// contains filtered or unexported fields
}
func NewHealthHandler ¶
func NewHealthHandler(logger *slog.Logger) *HealthHandler
func (*HealthHandler) ServeHTTP ¶
func (h *HealthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type NotFoundError ¶
Custom error types
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type ObjectHandler ¶
type ObjectHandler struct {
// contains filtered or unexported fields
}
ObjectHandler handles object storage operations
func NewObjectHandler ¶
func NewObjectHandler(client *minio.Client, logger *slog.Logger) (*ObjectHandler, error)
func (*ObjectHandler) RegisterRoutes ¶
func (h *ObjectHandler) RegisterRoutes(mux *http.ServeMux)
func (*ObjectHandler) ServeHTTP ¶
func (h *ObjectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ObjectResponse ¶
type PutObjectRequest ¶
type Request ¶
type Request struct { Method string PathParams map[string]string QueryParams map[string]string Headers http.Header Body []byte }
Request represents the base request structure
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
func NewStatsHandler ¶
func NewStatsHandler() *StatsHandler
func (*StatsHandler) RecordHit ¶
func (h *StatsHandler) RecordHit()
func (*StatsHandler) RecordMiss ¶
func (h *StatsHandler) RecordMiss()
func (*StatsHandler) ServeHTTP ¶
func (h *StatsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*StatsHandler) UpdateSize ¶
func (h *StatsHandler) UpdateSize(size int64)
type ValidationError ¶
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.