fix: need to create init for storage service to ensure it configures the http client after we have read the config
This commit is contained in:
parent
592b20c561
commit
ba44b58897
|
@ -125,6 +125,11 @@ func (p *PortalImpl) getInitFuncs() []func() error {
|
||||||
func() error {
|
func() error {
|
||||||
return protocols.Init(p.protocolRegistry)
|
return protocols.Init(p.protocolRegistry)
|
||||||
},
|
},
|
||||||
|
func() error {
|
||||||
|
p.storage.Init()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
func() error {
|
func() error {
|
||||||
return api.Init(p.apiRegistry)
|
return api.Init(p.apiRegistry)
|
||||||
},
|
},
|
||||||
|
|
|
@ -3,5 +3,6 @@ package interfaces
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
type StorageService interface {
|
type StorageService interface {
|
||||||
|
Init()
|
||||||
PutFile(file io.ReadSeeker, bucket string, generateProof bool) ([]byte, error)
|
PutFile(file io.ReadSeeker, bucket string, generateProof bool) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,14 +19,9 @@ type StorageServiceImpl struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStorageService(portal interfaces.Portal) interfaces.StorageService {
|
func NewStorageService(portal interfaces.Portal) interfaces.StorageService {
|
||||||
client := resty.New()
|
|
||||||
|
|
||||||
client.SetBaseURL(portal.Config().GetString("core.sia.url"))
|
|
||||||
client.SetBasicAuth("", portal.Config().GetString("core.sia.key"))
|
|
||||||
|
|
||||||
return &StorageServiceImpl{
|
return &StorageServiceImpl{
|
||||||
portal: portal,
|
portal: portal,
|
||||||
httpApi: client,
|
httpApi: nil,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,3 +57,12 @@ func (s StorageServiceImpl) PutFile(file io.ReadSeeker, bucket string, generateP
|
||||||
|
|
||||||
return hash[:], nil
|
return hash[:], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *StorageServiceImpl) Init() {
|
||||||
|
client := resty.New()
|
||||||
|
|
||||||
|
client.SetBaseURL(s.portal.Config().GetString("core.sia.url"))
|
||||||
|
client.SetBasicAuth("", s.portal.Config().GetString("core.sia.key"))
|
||||||
|
|
||||||
|
s.httpApi = client
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue