handlers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2025 License: GPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseIDFromPath

func ParseIDFromPath(r *http.Request, param string) (int, error)

ParseIDFromPath extracts an ID from the URL path This is a helper for chi router URL parameters

func RespondError

func RespondError(w http.ResponseWriter, status int, message string)

RespondError sends an error response

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, data any)

RespondJSON sends a JSON response

Types

type AddTorrentRequest

type AddTorrentRequest struct {
	Category     string   `json:"category,omitempty"`
	Tags         []string `json:"tags,omitempty"`
	StartPaused  bool     `json:"start_paused,omitempty"`
	SkipChecking bool     `json:"skip_checking,omitempty"`
	SavePath     string   `json:"save_path,omitempty"`
}

AddTorrentRequest represents a request to add a torrent

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(authService *auth.Service) *AuthHandler

func (*AuthHandler) ChangePassword

func (h *AuthHandler) ChangePassword(w http.ResponseWriter, r *http.Request)

ChangePassword handles password change requests

func (*AuthHandler) CheckSetupRequired

func (h *AuthHandler) CheckSetupRequired(w http.ResponseWriter, r *http.Request)

CheckSetupRequired checks if initial setup is required

func (*AuthHandler) CreateAPIKey

func (h *AuthHandler) CreateAPIKey(w http.ResponseWriter, r *http.Request)

CreateAPIKey creates a new API key

func (*AuthHandler) DeleteAPIKey

func (h *AuthHandler) DeleteAPIKey(w http.ResponseWriter, r *http.Request)

DeleteAPIKey deletes an API key

func (*AuthHandler) GetCurrentUser

func (h *AuthHandler) GetCurrentUser(w http.ResponseWriter, r *http.Request)

GetCurrentUser returns the current user information

func (*AuthHandler) ListAPIKeys

func (h *AuthHandler) ListAPIKeys(w http.ResponseWriter, r *http.Request)

ListAPIKeys returns all API keys

func (*AuthHandler) Login

func (h *AuthHandler) Login(w http.ResponseWriter, r *http.Request)

Login handles user login

func (*AuthHandler) Logout

func (h *AuthHandler) Logout(w http.ResponseWriter, r *http.Request)

Logout handles user logout

func (*AuthHandler) Setup

func (h *AuthHandler) Setup(w http.ResponseWriter, r *http.Request)

Setup handles initial user setup

type BulkActionRequest

type BulkActionRequest struct {
	Hashes      []string `json:"hashes"`
	Action      string   `json:"action"`
	DeleteFiles bool     `json:"deleteFiles,omitempty"` // For delete action
	Tags        string   `json:"tags,omitempty"`        // For tag operations (comma-separated)
	Category    string   `json:"category,omitempty"`    // For category operations
	Enable      bool     `json:"enable,omitempty"`      // For toggleAutoTMM action
}

BulkActionRequest represents a bulk action request

type ChangePasswordRequest

type ChangePasswordRequest struct {
	CurrentPassword string `json:"currentPassword"`
	NewPassword     string `json:"newPassword"`
}

ChangePasswordRequest represents a password change request

type CreateAPIKeyRequest

type CreateAPIKeyRequest struct {
	Name string `json:"name"`
}

CreateAPIKeyRequest represents a request to create an API key

type CreateInstanceRequest

type CreateInstanceRequest struct {
	Name          string  `json:"name"`
	Host          string  `json:"host"`
	Username      string  `json:"username"`
	Password      string  `json:"password"`
	BasicUsername *string `json:"basicUsername,omitempty"`
	BasicPassword *string `json:"basicPassword,omitempty"`
}

CreateInstanceRequest represents a request to create a new instance

type DeleteInstanceResponse

type DeleteInstanceResponse struct {
	Message string `json:"message"`
}

DeleteInstanceResponse represents delete operation result

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an API error response

type InstanceResponse

type InstanceResponse struct {
	ID              int        `json:"id"`
	Name            string     `json:"name"`
	Host            string     `json:"host"`
	Port            int        `json:"port"`
	Username        string     `json:"username"`
	BasicUsername   *string    `json:"basicUsername,omitempty"`
	IsActive        bool       `json:"isActive"`
	LastConnectedAt *time.Time `json:"lastConnectedAt,omitempty"`
	CreatedAt       time.Time  `json:"createdAt"`
	UpdatedAt       time.Time  `json:"updatedAt"`
	Connected       bool       `json:"connected"`
	ConnectionError string     `json:"connectionError,omitempty"`
}

InstanceResponse represents an instance in API responses

type InstanceStatsResponse

type InstanceStatsResponse struct {
	InstanceID int          `json:"instanceId"`
	Connected  bool         `json:"connected"`
	Torrents   TorrentStats `json:"torrents"`
	Speeds     SpeedStats   `json:"speeds"`
}

InstanceStatsResponse represents statistics for an instance

type InstancesHandler

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

func NewInstancesHandler

func NewInstancesHandler(instanceStore *models.InstanceStore, clientPool *internalqbittorrent.ClientPool, syncManager *internalqbittorrent.SyncManager) *InstancesHandler

func (*InstancesHandler) CreateInstance

func (h *InstancesHandler) CreateInstance(w http.ResponseWriter, r *http.Request)

CreateInstance creates a new instance

func (*InstancesHandler) DeleteInstance

func (h *InstancesHandler) DeleteInstance(w http.ResponseWriter, r *http.Request)

DeleteInstance deletes an instance

func (*InstancesHandler) GetInstanceStats

func (h *InstancesHandler) GetInstanceStats(w http.ResponseWriter, r *http.Request)

GetInstanceStats returns statistics for an instance

func (*InstancesHandler) ListInstances

func (h *InstancesHandler) ListInstances(w http.ResponseWriter, r *http.Request)

ListInstances returns all instances

func (*InstancesHandler) TestConnection

func (h *InstancesHandler) TestConnection(w http.ResponseWriter, r *http.Request)

TestConnection tests the connection to an instance

func (*InstancesHandler) UpdateInstance

func (h *InstancesHandler) UpdateInstance(w http.ResponseWriter, r *http.Request)

UpdateInstance updates an existing instance

type LicenseInfo

type LicenseInfo struct {
	LicenseKey string    `json:"licenseKey"`
	ThemeName  string    `json:"themeName"`
	Status     string    `json:"status"`
	CreatedAt  time.Time `json:"createdAt"`
}

LicenseInfo represents basic license information for UI display

type LoginRequest

type LoginRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

LoginRequest represents a login request

type PremiumAccessResponse

type PremiumAccessResponse struct {
	HasPremiumAccess bool `json:"hasPremiumAccess"`
}

PremiumAccessResponse represents the response for premium access status

type SetupRequest

type SetupRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

SetupRequest represents the initial setup request

type SpeedStats

type SpeedStats struct {
	Download int64 `json:"download"`
	Upload   int64 `json:"upload"`
}

SpeedStats represents download/upload speed statistics

type TestConnectionResponse

type TestConnectionResponse struct {
	Connected bool   `json:"connected"`
	Message   string `json:"message,omitempty"`
	Error     string `json:"error,omitempty"`
}

TestConnectionResponse represents connection test results

type ThemeLicenseHandler

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

ThemeLicenseHandler handles theme license related HTTP requests

func NewThemeLicenseHandler

func NewThemeLicenseHandler(themeLicenseService *services.ThemeLicenseService) *ThemeLicenseHandler

NewThemeLicenseHandler creates a new theme license handler

func (*ThemeLicenseHandler) DeleteLicense

func (h *ThemeLicenseHandler) DeleteLicense(w http.ResponseWriter, r *http.Request)

DeleteLicense removes a license from the system

func (*ThemeLicenseHandler) GetAllLicenses

func (h *ThemeLicenseHandler) GetAllLicenses(w http.ResponseWriter, r *http.Request)

GetAllLicenses returns all licenses for the current user

func (*ThemeLicenseHandler) GetLicensedThemes

func (h *ThemeLicenseHandler) GetLicensedThemes(w http.ResponseWriter, r *http.Request)

GetLicensedThemes returns premium access status

func (*ThemeLicenseHandler) RefreshLicenses

func (h *ThemeLicenseHandler) RefreshLicenses(w http.ResponseWriter, r *http.Request)

RefreshLicenses manually triggers a refresh of all licenses

func (*ThemeLicenseHandler) RegisterRoutes

func (h *ThemeLicenseHandler) RegisterRoutes(r chi.Router)

RegisterRoutes registers theme license routes

func (*ThemeLicenseHandler) ValidateLicense

func (h *ThemeLicenseHandler) ValidateLicense(w http.ResponseWriter, r *http.Request)

ValidateLicense validates and activates a theme license

type TorrentStats

type TorrentStats struct {
	Total       int `json:"total"`
	Downloading int `json:"downloading"`
	Seeding     int `json:"seeding"`
	Paused      int `json:"paused"`
	Error       int `json:"error"`
	Completed   int `json:"completed"`
}

TorrentStats represents torrent count statistics

type TorrentsHandler

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

func NewTorrentsHandler

func NewTorrentsHandler(syncManager *qbittorrent.SyncManager) *TorrentsHandler

func (*TorrentsHandler) AddTorrent

func (h *TorrentsHandler) AddTorrent(w http.ResponseWriter, r *http.Request)

AddTorrent adds a new torrent

func (*TorrentsHandler) BulkAction

func (h *TorrentsHandler) BulkAction(w http.ResponseWriter, r *http.Request)

BulkAction performs bulk operations on torrents

func (*TorrentsHandler) CreateCategory

func (h *TorrentsHandler) CreateCategory(w http.ResponseWriter, r *http.Request)

CreateCategory creates a new category

func (*TorrentsHandler) CreateTags

func (h *TorrentsHandler) CreateTags(w http.ResponseWriter, r *http.Request)

CreateTags creates new tags

func (*TorrentsHandler) DeleteTags

func (h *TorrentsHandler) DeleteTags(w http.ResponseWriter, r *http.Request)

DeleteTags deletes tags

func (*TorrentsHandler) DeleteTorrent

func (h *TorrentsHandler) DeleteTorrent(w http.ResponseWriter, r *http.Request)

DeleteTorrent deletes a single torrent

func (*TorrentsHandler) EditCategory

func (h *TorrentsHandler) EditCategory(w http.ResponseWriter, r *http.Request)

EditCategory edits an existing category

func (*TorrentsHandler) GetCategories

func (h *TorrentsHandler) GetCategories(w http.ResponseWriter, r *http.Request)

GetCategories returns all categories

func (*TorrentsHandler) GetFilteredTorrents

func (h *TorrentsHandler) GetFilteredTorrents(w http.ResponseWriter, r *http.Request)

GetFilteredTorrents returns filtered torrents

func (*TorrentsHandler) GetTags

func (h *TorrentsHandler) GetTags(w http.ResponseWriter, r *http.Request)

GetTags returns all tags

func (*TorrentsHandler) GetTorrentCounts

func (h *TorrentsHandler) GetTorrentCounts(w http.ResponseWriter, r *http.Request)

GetTorrentCounts returns torrent counts for filter sidebar

func (*TorrentsHandler) GetTorrentFiles

func (h *TorrentsHandler) GetTorrentFiles(w http.ResponseWriter, r *http.Request)

GetTorrentFiles returns files information for a specific torrent

func (*TorrentsHandler) GetTorrentProperties

func (h *TorrentsHandler) GetTorrentProperties(w http.ResponseWriter, r *http.Request)

GetTorrentProperties returns detailed properties for a specific torrent

func (*TorrentsHandler) GetTorrentTrackers

func (h *TorrentsHandler) GetTorrentTrackers(w http.ResponseWriter, r *http.Request)

GetTorrentTrackers returns trackers for a specific torrent

func (*TorrentsHandler) GetTorrentWebSeeds

func (h *TorrentsHandler) GetTorrentWebSeeds(w http.ResponseWriter, r *http.Request)

GetTorrentWebSeeds returns web seeds for a specific torrent

func (*TorrentsHandler) ListTorrents

func (h *TorrentsHandler) ListTorrents(w http.ResponseWriter, r *http.Request)

ListTorrents returns paginated torrents for an instance with enhanced metadata

func (*TorrentsHandler) PauseTorrent

func (h *TorrentsHandler) PauseTorrent(w http.ResponseWriter, r *http.Request)

PauseTorrent pauses a single torrent

func (*TorrentsHandler) RemoveCategories

func (h *TorrentsHandler) RemoveCategories(w http.ResponseWriter, r *http.Request)

RemoveCategories removes categories

func (*TorrentsHandler) ResumeTorrent

func (h *TorrentsHandler) ResumeTorrent(w http.ResponseWriter, r *http.Request)

ResumeTorrent resumes a single torrent

func (*TorrentsHandler) SyncTorrents

func (h *TorrentsHandler) SyncTorrents(w http.ResponseWriter, r *http.Request)

SyncTorrents returns sync updates for an instance

type UpdateInstanceRequest

type UpdateInstanceRequest struct {
	Name          string  `json:"name"`
	Host          string  `json:"host"`
	Username      string  `json:"username"`
	Password      string  `json:"password,omitempty"` // Optional for updates
	BasicUsername *string `json:"basicUsername,omitempty"`
	BasicPassword *string `json:"basicPassword,omitempty"`
}

UpdateInstanceRequest represents a request to update an instance

type ValidateLicenseRequest

type ValidateLicenseRequest struct {
	LicenseKey string `json:"licenseKey"`
}

ValidateLicenseRequest represents the request body for license validation

type ValidateLicenseResponse

type ValidateLicenseResponse struct {
	Valid     bool       `json:"valid"`
	ThemeName string     `json:"themeName,omitempty"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	Message   string     `json:"message,omitempty"`
	Error     string     `json:"error,omitempty"`
}

ValidateLicenseResponse represents the response for license validation

Jump to

Keyboard shortcuts

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