38 lines
623 B
Go
38 lines
623 B
Go
package app
|
|
|
|
import "net/http"
|
|
|
|
type Options struct {
|
|
DataDir string
|
|
DownloadDir string
|
|
Client *http.Client
|
|
}
|
|
|
|
func defaultOptions() *Options {
|
|
return &Options{
|
|
DataDir: "apps/data",
|
|
DownloadDir: "apps/download",
|
|
Client: &http.Client{},
|
|
}
|
|
}
|
|
|
|
type OptionFunc func(*Options)
|
|
|
|
func WithDataDir(dataDir string) OptionFunc {
|
|
return func(o *Options) {
|
|
o.DataDir = dataDir
|
|
}
|
|
}
|
|
|
|
func WithDownloadDir(downloadDir string) OptionFunc {
|
|
return func(o *Options) {
|
|
o.DownloadDir = downloadDir
|
|
}
|
|
}
|
|
|
|
func WithClient(client *http.Client) OptionFunc {
|
|
return func(o *Options) {
|
|
o.Client = client
|
|
}
|
|
}
|