photoprism/internal/hub/request.go

41 lines
851 B
Go
Raw Normal View History

2020-12-04 12:10:32 +00:00
package hub
import (
"net/url"
"runtime"
)
2020-12-04 12:10:32 +00:00
var ServiceURL = "https://hub.photoprism.app/v1/hello"
2020-12-04 12:10:32 +00:00
// Backend api credentials request incl basic runtime specs.
type Request struct {
ClientVersion string `json:"ClientVersion"`
ClientSerial string `json:"ClientSerial"`
ClientOS string `json:"ClientOS"`
ClientArch string `json:"ClientArch"`
ClientCPU int `json:"ClientCPU"`
}
2020-12-04 12:10:32 +00:00
// NewRequest creates a new hub key request instance.
func NewRequest(version, serial string) *Request {
return &Request{
ClientVersion: version,
ClientSerial: serial,
ClientOS: runtime.GOOS,
ClientArch: runtime.GOARCH,
ClientCPU: runtime.NumCPU(),
}
}
// ApiHost returns the full API URL host name.
func ApiHost() string {
2020-12-04 12:10:32 +00:00
u, err := url.Parse(ServiceURL)
if err != nil {
log.Warn(err)
return ""
}
return u.Host
}