mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-27 02:10:40 +00:00
Move httpsig algos slice to an init() function
This commit is contained in:
parent
76f06cee31
commit
d1f14ff2c7
1 changed files with 9 additions and 4 deletions
|
@ -54,6 +54,15 @@ 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 {
|
||||
|
@ -61,10 +70,6 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) {
|
|||
} else if err = containsRequiredHTTPHeaders(http.MethodPost, setting.Federation.PostHeaders); err != nil {
|
||||
return
|
||||
}
|
||||
algos := make([]httpsig.Algorithm, len(setting.Federation.Algorithms))
|
||||
for i, algo := range setting.Federation.Algorithms {
|
||||
algos[i] = httpsig.Algorithm(algo)
|
||||
}
|
||||
|
||||
priv, err := GetPrivateKey(user)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue