Skip to content

Commit

Permalink
Merge pull request #4 from golift/dn2_simple
Browse files Browse the repository at this point in the history
Simpler interface
  • Loading branch information
davidnewhall authored Jul 9, 2022
2 parents 51ab099 + 0758bb0 commit 1cd6839
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 120 deletions.
26 changes: 8 additions & 18 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package deluge

import (
"encoding/json"
"time"
"net/http"
)

// Deluge WebUI methods.
Expand All @@ -19,23 +19,13 @@ const (

// Config is the data needed to poll Deluge.
type Config struct {
VerifySSL bool `json:"verify_ssl" toml:"verify_ssl" xml:"verify_ssl" yaml:"verify_ssl"`
Timeout Duration `json:"timeout" toml:"timeout" xml:"timeout" yaml:"timeout"`
URL string `json:"url" toml:"url" xml:"url" yaml:"url"`
Password string `json:"password" toml:"password" xml:"password" yaml:"password"`
HTTPPass string `json:"http_pass" toml:"http_pass" xml:"http_pass" yaml:"http_pass"`
HTTPUser string `json:"http_user" toml:"http_user" xml:"http_user" yaml:"http_user"`
Version string `json:"version" toml:"version" xml:"version" yaml:"version"`
DebugLog func(msg string, fmt ...interface{}) `json:"-" toml:"-" xml:"-" yaml:"-"`
}

// Duration is used to UnmarshalTOML into a time.Duration value.
type Duration struct{ time.Duration }

// UnmarshalText parses a duration type from a config file.
func (d *Duration) UnmarshalText(data []byte) (err error) {
d.Duration, err = time.ParseDuration(string(data))
return
URL string `json:"url" toml:"url" xml:"url" yaml:"url"`
Password string `json:"password" toml:"password" xml:"password" yaml:"password"`
HTTPPass string `json:"http_pass" toml:"http_pass" xml:"http_pass" yaml:"http_pass"`
HTTPUser string `json:"http_user" toml:"http_user" xml:"http_user" yaml:"http_user"`
Version string `json:"version" toml:"version" xml:"version" yaml:"version"`
DebugLog func(msg string, fmt ...interface{}) `json:"-" toml:"-" xml:"-" yaml:"-"`
Client *http.Client `json:"-" toml:"-" xml:"-" yaml:"-"`
}

// Response from Deluge
Expand Down
Loading

0 comments on commit 1cd6839

Please sign in to comment.