handlers

package
v0.0.0-...-d43a3fe Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthCheck

func HealthCheck(c *fiber.Ctx) error

HealthCheck handles the health check endpoint @Summary Health check @Description Check if the service is running @Tags health @Accept json @Produce json @Success 200 {object} HealthResponse @Router /health [get]

func SetupHealthRoutes

func SetupHealthRoutes(app *fiber.App)

SetupHealthRoutes configures health check routes

func SetupRoutes

func SetupRoutes(app *fiber.App, cfg *config.Config, store storage.Storage, conv *factory.ConverterFactory, logger *slog.Logger)

SetupRoutes configures all the routes for the application

Types

type Conversion

type Conversion struct {
	ID            string    `json:"id"`
	Status        string    `json:"status"`
	SourceFormat  string    `json:"source_format"`
	TargetFormat  string    `json:"target_format"`
	OriginalName  string    `json:"original_name"`
	ConvertedName string    `json:"converted_name,omitempty"`
	FileSize      int64     `json:"file_size"`
	CreatedAt     time.Time `json:"created_at"`
	CompletedAt   time.Time `json:"completed_at,omitempty"`
	DownloadURL   string    `json:"download_url,omitempty"`
	Error         string    `json:"error,omitempty"`
}

Conversion represents a file conversion @Description File conversion details

type FileHeader

type FileHeader struct {
	*multipart.FileHeader
}

FileHeader wraps multipart.FileHeader to implement our interface

func (*FileHeader) Filename

func (f *FileHeader) Filename() string

Filename returns the name of the file

func (*FileHeader) Open

func (f *FileHeader) Open() (multipart.File, error)

Open returns a ReadCloser for the file

func (*FileHeader) Size

func (f *FileHeader) Size() int64

Size returns the size of the file in bytes

type Handler

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

Handler provides application handlers

func NewHandler

func NewHandler(cfg *config.Config, store storage.Storage, factory *factory.ConverterFactory, log *slog.Logger) *Handler

NewHandler creates a new handler instance

func (*Handler) AdminDashboard

func (h *Handler) AdminDashboard(c *fiber.Ctx) error

AdminDashboard returns admin dashboard stats

func (*Handler) ConvertFile

func (h *Handler) ConvertFile(c *fiber.Ctx) error

ConvertFile handles file conversion requests @Summary Convert a file to another format @Description Converts an uploaded file to the specified target format @Tags files @Accept multipart/form-data @Produce json @Param file formData file true "File to convert" @Param format formData string true "Target format to convert to" @Success 200 {object} map[string]interface{} @Failure 400 {object} map[string]interface{} @Failure 500 {object} map[string]interface{} @Router /api/v1/convert [post]

func (*Handler) DeleteConversion

func (h *Handler) DeleteConversion(c *fiber.Ctx) error

DeleteConversion deletes a conversion @Summary Delete conversion @Description Deletes a file conversion by ID @Tags conversion @Param id path string true "Conversion ID" @Success 204 @Failure 404 {object} map[string]interface{} @Router /api/v1/convert/{id} [delete]

func (*Handler) DeleteUser

func (h *Handler) DeleteUser(c *fiber.Ctx) error

DeleteUser deletes a user

func (*Handler) DownloadFile

func (h *Handler) DownloadFile(c *fiber.Ctx) error

DownloadFile downloads a converted file @Summary Download converted file @Description Downloads a converted file by ID @Tags conversion @Produce octet-stream @Param id path string true "Conversion ID" @Success 200 @Failure 404 {object} map[string]interface{} @Router /api/v1/convert/{id}/download [get]

func (*Handler) GetConversion

func (h *Handler) GetConversion(c *fiber.Ctx) error

GetConversion gets a single conversion by ID @Summary Get conversion @Description Gets a file conversion by ID @Tags conversion @Produce json @Param id path string true "Conversion ID" @Success 200 {object} Conversion @Failure 404 {object} map[string]interface{} @Router /api/v1/convert/{id} [get]

func (*Handler) GetConversionStatus

func (h *Handler) GetConversionStatus(c *fiber.Ctx) error

GetConversionStatus gets the status of a conversion @Summary Get conversion status @Description Gets the status of a file conversion by ID @Tags conversion @Produce json @Param id path string true "Conversion ID" @Success 200 {object} Conversion @Failure 404 {object} map[string]interface{} @Router /api/v1/convert/{id}/status [get]

func (*Handler) GetSettings

func (h *Handler) GetSettings(c *fiber.Ctx) error

GetSettings returns system settings

func (*Handler) GetStats

func (h *Handler) GetStats(c *fiber.Ctx) error

GetStats returns system statistics

func (*Handler) GetUser

func (h *Handler) GetUser(c *fiber.Ctx) error

GetUser gets a user by ID

func (*Handler) HealthCheck

func (h *Handler) HealthCheck(c *fiber.Ctx) error

HealthCheck handles health check requests

func (*Handler) ListConversions

func (h *Handler) ListConversions(c *fiber.Ctx) error

ListConversions lists all conversions @Summary List conversions @Description Lists all file conversions @Tags conversion @Produce json @Success 200 {array} Conversion @Router /api/v1/convert [get]

func (*Handler) ListUsers

func (h *Handler) ListUsers(c *fiber.Ctx) error

ListUsers lists all users (admin only)

func (*Handler) Login

func (h *Handler) Login(c *fiber.Ctx) error

Login handles user authentication

func (*Handler) RefreshToken

func (h *Handler) RefreshToken(c *fiber.Ctx) error

RefreshToken handles token refresh

func (*Handler) Register

func (h *Handler) Register(c *fiber.Ctx) error

Register handles user registration

func (*Handler) UpdateSettings

func (h *Handler) UpdateSettings(c *fiber.Ctx) error

UpdateSettings updates system settings

func (*Handler) UpdateUser

func (h *Handler) UpdateUser(c *fiber.Ctx) error

UpdateUser updates a user

type HealthResponse

type HealthResponse struct {
	Status  string `json:"status"`
	Version string `json:"version"`
	Uptime  string `json:"uptime,omitempty"`
}

HealthResponse represents the health check response structure

Jump to

Keyboard shortcuts

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