Move httpsig algs constant slice to modules/setting/federation.go
This commit is contained in:
parent
e60158c70b
commit
a4403e4e80
|
@ -55,15 +55,6 @@ type Client struct {
|
|||
pubID string
|
||||
}
|
||||
|
||||
var algos []httpsig.Algorithm
|
||||
|
||||
func init() {
|
||||
algos = make([]httpsig.Algorithm, len(setting.Federation.Algorithms))
|
||||
for i, algo := range setting.Federation.Algorithms {
|
||||
algos[i] = httpsig.Algorithm(algo)
|
||||
}
|
||||
}
|
||||
|
||||
// NewClient function
|
||||
func NewClient(user *user_model.User, pubID string) (c *Client, err error) {
|
||||
if err = containsRequiredHTTPHeaders(http.MethodGet, setting.Federation.GetHeaders); err != nil {
|
||||
|
@ -88,7 +79,7 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) {
|
|||
Proxy: proxy.Proxy(),
|
||||
},
|
||||
},
|
||||
algs: algos,
|
||||
algs: setting.HttpsigAlgs,
|
||||
digestAlg: httpsig.DigestAlgorithm(setting.Federation.DigestAlgorithm),
|
||||
getHeaders: setting.Federation.GetHeaders,
|
||||
postHeaders: setting.Federation.PostHeaders,
|
||||
|
|
|
@ -29,6 +29,9 @@ var (
|
|||
}
|
||||
)
|
||||
|
||||
// Constant slice of httpsig algorithm objects
|
||||
var HttpsigAlgs []httpsig.Algorithm
|
||||
|
||||
func newFederationService() {
|
||||
if err := Cfg.Section("federation").MapTo(&Federation); err != nil {
|
||||
log.Fatal("Failed to map Federation settings: %v", err)
|
||||
|
@ -36,4 +39,9 @@ func newFederationService() {
|
|||
log.Fatal("unsupported digest algorithm: %s", Federation.DigestAlgorithm)
|
||||
return
|
||||
}
|
||||
|
||||
HttpsigAlgs = make([]httpsig.Algorithm, len(Federation.Algorithms))
|
||||
for i, alg := range Federation.Algorithms {
|
||||
HttpsigAlgs[i] = httpsig.Algorithm(alg)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue