gofmt
This commit is contained in:
parent
64ca86effa
commit
d1605ee841
2
main.go
2
main.go
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"flag"
|
||||||
|
|
||||||
"dev.sum7.eu/genofire/golang-lib/file"
|
"dev.sum7.eu/genofire/golang-lib/file"
|
||||||
"github.com/bdlm/log"
|
"github.com/bdlm/log"
|
||||||
|
|
|
@ -2,16 +2,16 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
"fmt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *configData) Request(url string, value interface{}) error {
|
func (c *configData) Request(url string, value interface{}) error {
|
||||||
netClient := &http.Client{
|
netClient := &http.Client{
|
||||||
Timeout: time.Second * 20,
|
Timeout: time.Second * 20,
|
||||||
}
|
}
|
||||||
req, err := http.NewRequest(http.MethodGet, c.Host + url, nil)
|
req, err := http.NewRequest(http.MethodGet, c.Host+url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,3 @@ func (c *configData) Request(url string, value interface{}) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ const (
|
||||||
URLRequestListVHost = "/v1/vhosts"
|
URLRequestListVHost = "/v1/vhosts"
|
||||||
URLRequestListApp = "/v1/vhosts/%s/apps"
|
URLRequestListApp = "/v1/vhosts/%s/apps"
|
||||||
URLRequestListStream = "/v1/vhosts/%s/apps/%s/streams"
|
URLRequestListStream = "/v1/vhosts/%s/apps/%s/streams"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResponseList struct {
|
type ResponseList struct {
|
||||||
|
@ -20,7 +19,7 @@ type ResponseList struct {
|
||||||
func (c *configData) RequestListVHosts() (*ResponseList, error) {
|
func (c *configData) RequestListVHosts() (*ResponseList, error) {
|
||||||
req := ResponseList{}
|
req := ResponseList{}
|
||||||
url := fmt.Sprintf(URLRequestListVHost)
|
url := fmt.Sprintf(URLRequestListVHost)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
@ -29,7 +28,7 @@ func (c *configData) RequestListVHosts() (*ResponseList, error) {
|
||||||
func (c *configData) RequestListApps(vhost string) (*ResponseList, error) {
|
func (c *configData) RequestListApps(vhost string) (*ResponseList, error) {
|
||||||
req := ResponseList{}
|
req := ResponseList{}
|
||||||
url := fmt.Sprintf(URLRequestListApp, vhost)
|
url := fmt.Sprintf(URLRequestListApp, vhost)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
@ -38,7 +37,7 @@ func (c *configData) RequestListApps(vhost string) (*ResponseList, error) {
|
||||||
func (c *configData) RequestListStreams(vhost, app string) (*ResponseList, error) {
|
func (c *configData) RequestListStreams(vhost, app string) (*ResponseList, error) {
|
||||||
req := ResponseList{}
|
req := ResponseList{}
|
||||||
url := fmt.Sprintf(URLRequestListStream, vhost, app)
|
url := fmt.Sprintf(URLRequestListStream, vhost, app)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
|
|
@ -10,7 +10,6 @@ const (
|
||||||
URLRequestStatsVHost = "/v1/stats/current/vhosts/%s"
|
URLRequestStatsVHost = "/v1/stats/current/vhosts/%s"
|
||||||
URLRequestStatsApp = "/v1/stats/current/vhosts/%s/apps/%s"
|
URLRequestStatsApp = "/v1/stats/current/vhosts/%s/apps/%s"
|
||||||
URLRequestStatsStream = "/v1/stats/current/vhosts/%s/apps/%s/streams/%s"
|
URLRequestStatsStream = "/v1/stats/current/vhosts/%s/apps/%s/streams/%s"
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ResponseStats struct {
|
type ResponseStats struct {
|
||||||
|
@ -34,7 +33,6 @@ type ResponseStatsData struct {
|
||||||
TotalBytesOut uint64 `json:"totalBytesOut" example:"117022184"`
|
TotalBytesOut uint64 `json:"totalBytesOut" example:"117022184"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func (resp *ResponseStats) Log(log *log.Entry) {
|
func (resp *ResponseStats) Log(log *log.Entry) {
|
||||||
logger := log
|
logger := log
|
||||||
if resp.Data != nil {
|
if resp.Data != nil {
|
||||||
|
@ -48,7 +46,7 @@ func (resp *ResponseStats) Log(log *log.Entry) {
|
||||||
func (c *configData) RequestStatsVHost(vhost string) (*ResponseStats, error) {
|
func (c *configData) RequestStatsVHost(vhost string) (*ResponseStats, error) {
|
||||||
req := ResponseStats{}
|
req := ResponseStats{}
|
||||||
url := fmt.Sprintf(URLRequestStatsVHost, vhost)
|
url := fmt.Sprintf(URLRequestStatsVHost, vhost)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
@ -57,7 +55,7 @@ func (c *configData) RequestStatsVHost(vhost string) (*ResponseStats, error) {
|
||||||
func (c *configData) RequestStatsApp(vhost, app string) (*ResponseStats, error) {
|
func (c *configData) RequestStatsApp(vhost, app string) (*ResponseStats, error) {
|
||||||
req := ResponseStats{}
|
req := ResponseStats{}
|
||||||
url := fmt.Sprintf(URLRequestStatsApp, vhost, app)
|
url := fmt.Sprintf(URLRequestStatsApp, vhost, app)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
@ -66,7 +64,7 @@ func (c *configData) RequestStatsApp(vhost, app string) (*ResponseStats, error)
|
||||||
func (c *configData) RequestStatsStream(vhost, app, stream string) (*ResponseStats, error) {
|
func (c *configData) RequestStatsStream(vhost, app, stream string) (*ResponseStats, error) {
|
||||||
req := ResponseStats{}
|
req := ResponseStats{}
|
||||||
url := fmt.Sprintf(URLRequestStatsStream, vhost, app, stream)
|
url := fmt.Sprintf(URLRequestStatsStream, vhost, app, stream)
|
||||||
if err := c.Request(url, &req); err != nil{
|
if err := c.Request(url, &req); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &req, nil
|
return &req, nil
|
||||||
|
|
Loading…
Reference in New Issue