handlers

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: GPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 ActivateLicenseRequest added in v1.0.0

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

ActivateLicenseRequest represents the request body for license activation

type ActivateLicenseResponse added in v1.0.0

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

ActivateLicenseResponse represents the response for license activation

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 AddTrackerRequest added in v1.0.0

type AddTrackerRequest struct {
	URLs string `json:"urls"` // Newline-separated URLs
}

AddTrackerRequest represents a tracker add request

type AuthHandler

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

func NewAuthHandler

func NewAuthHandler(
	authService *auth.Service,
	sessionManager *scs.SessionManager,
	instanceStore *models.InstanceStore,
	clientPool *qbittorrent.ClientPool,
	syncManager *qbittorrent.SyncManager,
) *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
	SelectAll                bool                       `json:"selectAll,omitempty"`                // When true, apply to all torrents matching filters
	Filters                  *qbittorrent.FilterOptions `json:"filters,omitempty"`                  // Filters to apply when selectAll is true
	Search                   string                     `json:"search,omitempty"`                   // Search query when selectAll is true
	ExcludeHashes            []string                   `json:"excludeHashes,omitempty"`            // Hashes to exclude when selectAll is true
	RatioLimit               float64                    `json:"ratioLimit,omitempty"`               // For setShareLimit action
	SeedingTimeLimit         int64                      `json:"seedingTimeLimit,omitempty"`         // For setShareLimit action
	InactiveSeedingTimeLimit int64                      `json:"inactiveSeedingTimeLimit,omitempty"` // For setShareLimit action
	UploadLimit              int64                      `json:"uploadLimit,omitempty"`              // For setUploadLimit action (KB/s)
	DownloadLimit            int64                      `json:"downloadLimit,omitempty"`            // For setDownloadLimit action (KB/s)
	Location                 string                     `json:"location,omitempty"`                 // For setLocation action
	TrackerOldURL            string                     `json:"trackerOldURL,omitempty"`            // For editTrackers action
	TrackerNewURL            string                     `json:"trackerNewURL,omitempty"`            // For editTrackers action
	TrackerURLs              string                     `json:"trackerURLs,omitempty"`              // For addTrackers/removeTrackers actions
}

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 CheckResult added in v1.0.0

type CheckResult struct {
	Status string `json:"status"`
	Error  string `json:"error,omitempty"`
}

type ClientAPIKeyWithInstance added in v1.0.0

type ClientAPIKeyWithInstance struct {
	*models.ClientAPIKey
	Instance *models.Instance `json:"instance"`
}

type ClientAPIKeysHandler added in v1.0.0

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

func NewClientAPIKeysHandler added in v1.0.0

func NewClientAPIKeysHandler(clientAPIKeyStore *models.ClientAPIKeyStore, instanceStore *models.InstanceStore) *ClientAPIKeysHandler

func (*ClientAPIKeysHandler) CreateClientAPIKey added in v1.0.0

func (h *ClientAPIKeysHandler) CreateClientAPIKey(w http.ResponseWriter, r *http.Request)

CreateClientAPIKey handles POST /api/client-api-keys

func (*ClientAPIKeysHandler) DeleteClientAPIKey added in v1.0.0

func (h *ClientAPIKeysHandler) DeleteClientAPIKey(w http.ResponseWriter, r *http.Request)

DeleteClientAPIKey handles DELETE /api/client-api-keys/{id}

func (*ClientAPIKeysHandler) ListClientAPIKeys added in v1.0.0

func (h *ClientAPIKeysHandler) ListClientAPIKeys(w http.ResponseWriter, r *http.Request)

ListClientAPIKeys handles GET /api/client-api-keys

type CreateAPIKeyRequest

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

CreateAPIKeyRequest represents a request to create an API key

type CreateClientAPIKeyRequest added in v1.0.0

type CreateClientAPIKeyRequest struct {
	ClientName string `json:"clientName"`
	InstanceID int    `json:"instanceId"`
}

type CreateClientAPIKeyResponse added in v1.0.0

type CreateClientAPIKeyResponse struct {
	Key          string               `json:"key"`
	ClientAPIKey *models.ClientAPIKey `json:"clientApiKey"`
	Instance     *models.Instance     `json:"instance,omitempty"`
	ProxyURL     string               `json:"proxyUrl"`
}

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"`
	TLSSkipVerify bool    `json:"tlsSkipVerify,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 EditTrackerRequest added in v1.0.0

type EditTrackerRequest struct {
	OldURL string `json:"oldURL"`
	NewURL string `json:"newURL"`
}

EditTrackerRequest represents a tracker edit request

type ErrorResponse

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

ErrorResponse represents an API error response

type HealthHandler added in v1.0.0

type HealthHandler struct {
}

func NewHealthHandler added in v1.0.0

func NewHealthHandler() *HealthHandler

func (*HealthHandler) HandleHealth added in v1.0.0

func (h *HealthHandler) HandleHealth(w http.ResponseWriter, r *http.Request)

func (*HealthHandler) HandleLiveness added in v1.0.0

func (h *HealthHandler) HandleLiveness(w http.ResponseWriter, r *http.Request)

func (*HealthHandler) HandleReady added in v1.0.0

func (h *HealthHandler) HandleReady(w http.ResponseWriter, r *http.Request)

func (*HealthHandler) Routes added in v1.0.0

func (h *HealthHandler) Routes(r chi.Router)

type HealthResponse added in v1.0.0

type HealthResponse struct {
	Status    string                 `json:"status"`
	Checks    map[string]CheckResult `json:"checks,omitempty"`
	Timestamp time.Time              `json:"timestamp"`
}

type InstanceResponse

type InstanceResponse struct {
	ID                 int                    `json:"id"`
	Name               string                 `json:"name"`
	Host               string                 `json:"host"`
	Username           string                 `json:"username"`
	BasicUsername      *string                `json:"basicUsername,omitempty"`
	TLSSkipVerify      bool                   `json:"tlsSkipVerify"`
	Connected          bool                   `json:"connected"`
	HasDecryptionError bool                   `json:"hasDecryptionError"`
	RecentErrors       []models.InstanceError `json:"recentErrors,omitempty"`
}

InstanceResponse represents an instance in API responses

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) 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 LatestVersionResponse added in v1.1.0

type LatestVersionResponse struct {
	TagName     string `json:"tag_name"`
	Name        string `json:"name,omitempty"`
	HTMLURL     string `json:"html_url"`
	PublishedAt string `json:"published_at"`
}

type LicenseHandler added in v1.0.0

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

LicenseHandler handles license related HTTP requests

func NewLicenseHandler added in v1.0.0

func NewLicenseHandler(licenseService *license.Service) *LicenseHandler

NewLicenseHandler creates a new license handler

func (*LicenseHandler) ActivateLicense added in v1.0.0

func (h *LicenseHandler) ActivateLicense(w http.ResponseWriter, r *http.Request)

ActivateLicense activates a license

func (*LicenseHandler) DeleteLicense added in v1.0.0

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

DeleteLicense removes a license from the system

func (*LicenseHandler) GetAllLicenses added in v1.0.0

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

GetAllLicenses returns all licenses for the current user

func (*LicenseHandler) GetLicensedThemes added in v1.0.0

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

GetLicensedThemes returns premium access status

func (*LicenseHandler) RefreshLicenses added in v1.0.0

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

RefreshLicenses manually triggers a refresh of all licenses

func (*LicenseHandler) Routes added in v1.0.0

func (h *LicenseHandler) Routes(r chi.Router)

func (*LicenseHandler) ValidateLicense added in v1.0.0

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

ValidateLicense validates a license

type LicenseInfo

type LicenseInfo struct {
	LicenseKey  string    `json:"licenseKey"`
	ProductName string    `json:"productName"`
	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"`
	RememberMe bool   `json:"remember_me"`
}

LoginRequest represents a login request

type PreferencesHandler added in v0.3.0

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

func NewPreferencesHandler added in v0.3.0

func NewPreferencesHandler(syncManager *qbittorrent.SyncManager) *PreferencesHandler

func (*PreferencesHandler) GetAlternativeSpeedLimitsMode added in v0.3.0

func (h *PreferencesHandler) GetAlternativeSpeedLimitsMode(w http.ResponseWriter, r *http.Request)

GetAlternativeSpeedLimitsMode returns the current alternative speed limits mode

func (*PreferencesHandler) GetPreferences added in v0.3.0

func (h *PreferencesHandler) GetPreferences(w http.ResponseWriter, r *http.Request)

GetPreferences returns app preferences for an instance TODO: The go-qbittorrent library is missing network interface list endpoints: - /api/v2/app/networkInterfaceList (to get available network interfaces) - /api/v2/app/networkInterfaceAddressList (to get addresses for an interface) These are needed to properly populate network interface dropdowns like the official WebUI. For now, current_network_interface and current_interface_address show actual values but cannot be configured with proper dropdown selections.

func (*PreferencesHandler) ToggleAlternativeSpeedLimits added in v0.3.0

func (h *PreferencesHandler) ToggleAlternativeSpeedLimits(w http.ResponseWriter, r *http.Request)

ToggleAlternativeSpeedLimits toggles alternative speed limits on/off

func (*PreferencesHandler) UpdatePreferences added in v0.3.0

func (h *PreferencesHandler) UpdatePreferences(w http.ResponseWriter, r *http.Request)

UpdatePreferences updates specific preference fields

type PremiumAccessResponse

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

PremiumAccessResponse represents the response for premium access status

type RemoveTrackerRequest added in v1.0.0

type RemoveTrackerRequest struct {
	URLs string `json:"urls"` // Newline-separated URLs
}

RemoveTrackerRequest represents a tracker remove request

type SetupRequest

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

SetupRequest represents the initial setup request

type SortedPeer added in v1.0.0

type SortedPeer struct {
	Key string `json:"key"`
	qbt.TorrentPeer
}

SortedPeer represents a peer with its key for sorting

type SortedPeersResponse added in v1.0.0

type SortedPeersResponse struct {
	*qbt.TorrentPeersResponse
	SortedPeers []SortedPeer `json:"sorted_peers,omitempty"`
}

SortedPeersResponse wraps the peers response with sorted peers

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 TorrentsHandler

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

func NewTorrentsHandler

func NewTorrentsHandler(syncManager *qbittorrent.SyncManager) *TorrentsHandler

func (*TorrentsHandler) AddPeers added in v1.0.0

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

AddPeers adds peers to torrents

func (*TorrentsHandler) AddTorrent

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

AddTorrent adds a new torrent

func (*TorrentsHandler) AddTorrentTrackers added in v1.0.0

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

AddTorrentTrackers adds trackers to a specific torrent

func (*TorrentsHandler) BanPeers added in v1.0.0

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

BanPeers bans peers permanently

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) EditCategory

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

EditCategory edits an existing category

func (*TorrentsHandler) EditTorrentTracker added in v1.0.0

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

EditTorrentTracker edits a tracker URL for a specific torrent

func (*TorrentsHandler) GetCategories

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

GetCategories returns all categories

func (*TorrentsHandler) GetTags

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

GetTags returns all tags

func (*TorrentsHandler) GetTorrentFiles

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

func (*TorrentsHandler) GetTorrentPeers added in v1.0.0

func (h *TorrentsHandler) GetTorrentPeers(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) ListTorrents

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

ListTorrents returns paginated torrents for an instance with enhanced metadata

func (*TorrentsHandler) RemoveCategories

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

RemoveCategories removes categories

func (*TorrentsHandler) RemoveTorrentTrackers added in v1.0.0

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

RemoveTorrentTrackers removes trackers from a specific torrent

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"`
	TLSSkipVerify *bool   `json:"tlsSkipVerify,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"`
	ProductName string     `json:"productName,omitempty"`
	ExpiresAt   *time.Time `json:"expiresAt,omitempty"`
	Message     string     `json:"message,omitempty"`
	Error       string     `json:"error,omitempty"`
}

ValidateLicenseResponse represents the response for license validation

type VersionHandler added in v1.1.0

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

func NewVersionHandler added in v1.1.0

func NewVersionHandler(updateService *update.Service) *VersionHandler

func (*VersionHandler) GetLatestVersion added in v1.1.0

func (h *VersionHandler) GetLatestVersion(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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