Documentation
¶
Overview ¶
Package api provides HTTP API handlers for the WarpDL daemon server. It coordinates request handling between the server and the download manager, exposing endpoints for download operations and extension management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Api ¶
type Api struct {
// contains filtered or unexported fields
}
Api coordinates request handling between the server and download manager. It encapsulates the download manager, extension engine, HTTP client, and scheme router required to process download and extension management requests.
func NewApi ¶
func NewApi(l *log.Logger, m *warplib.Manager, client *http.Client, elEngine *extl.Engine, router *warplib.SchemeRouter, sched *scheduler.Scheduler, version, commit, buildType string) (*Api, error)
NewApi creates a new Api instance with the provided dependencies. It returns an initialized Api ready to handle download and extension requests. The logger is used for diagnostic output, the manager handles download state, the client performs HTTP requests, the elEngine manages JavaScript extensions, and the router dispatches FTP/FTPS URLs to the correct protocol downloader. The router may be nil if FTP support is not needed. Version info (version, commit, buildType) is stored for responding to version queries.
func (*Api) Close ¶
Close releases resources held by the Api, specifically closing the underlying download manager. It returns any error encountered during the close operation.
func (*Api) RegisterHandlers ¶
RegisterHandlers registers all API handlers with the provided server. It sets up handlers for download operations (download, resume, attach, flush, stop, list) and extension management operations (add, get, list, delete, activate, deactivate).