From d1605ee841ca030df2074acb0b939e5787b06652 Mon Sep 17 00:00:00 2001 From: Geno Date: Tue, 20 Jul 2021 12:25:05 +0200 Subject: [PATCH] gofmt --- main.go | 2 +- request.go | 5 ++--- response_lists.go | 17 ++++++++--------- response_stats.go | 30 ++++++++++++++---------------- 4 files changed, 25 insertions(+), 29 deletions(-) diff --git a/main.go b/main.go index b86ad40..a85c741 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ package main import ( - "flag" "encoding/base64" + "flag" "dev.sum7.eu/genofire/golang-lib/file" "github.com/bdlm/log" diff --git a/request.go b/request.go index 613f547..63af99c 100644 --- a/request.go +++ b/request.go @@ -2,16 +2,16 @@ package main import ( "encoding/json" + "fmt" "net/http" "time" - "fmt" ) func (c *configData) Request(url string, value interface{}) error { netClient := &http.Client{ 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 { return err } @@ -30,4 +30,3 @@ func (c *configData) Request(url string, value interface{}) error { } return nil } - diff --git a/response_lists.go b/response_lists.go index b463fb7..2695c75 100644 --- a/response_lists.go +++ b/response_lists.go @@ -5,22 +5,21 @@ import ( ) const ( - URLRequestListVHost = "/v1/vhosts" - URLRequestListApp = "/v1/vhosts/%s/apps" + URLRequestListVHost = "/v1/vhosts" + URLRequestListApp = "/v1/vhosts/%s/apps" URLRequestListStream = "/v1/vhosts/%s/apps/%s/streams" - ) type ResponseList struct { - Message string `json:"message"` - StatusCode int `json:"statusCode"` - Data []string `json:"response,omitempty"` + Message string `json:"message"` + StatusCode int `json:"statusCode"` + Data []string `json:"response,omitempty"` } func (c *configData) RequestListVHosts() (*ResponseList, error) { req := ResponseList{} url := fmt.Sprintf(URLRequestListVHost) - if err := c.Request(url, &req); err != nil{ + if err := c.Request(url, &req); err != nil { return nil, err } return &req, nil @@ -29,7 +28,7 @@ func (c *configData) RequestListVHosts() (*ResponseList, error) { func (c *configData) RequestListApps(vhost string) (*ResponseList, error) { req := ResponseList{} 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 &req, nil @@ -38,7 +37,7 @@ func (c *configData) RequestListApps(vhost string) (*ResponseList, error) { func (c *configData) RequestListStreams(vhost, app string) (*ResponseList, error) { req := ResponseList{} 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 &req, nil diff --git a/response_stats.go b/response_stats.go index 77d91c0..552edd7 100644 --- a/response_stats.go +++ b/response_stats.go @@ -7,16 +7,15 @@ import ( ) const ( - URLRequestStatsVHost = "/v1/stats/current/vhosts/%s" - URLRequestStatsApp = "/v1/stats/current/vhosts/%s/apps/%s" + URLRequestStatsVHost = "/v1/stats/current/vhosts/%s" + URLRequestStatsApp = "/v1/stats/current/vhosts/%s/apps/%s" URLRequestStatsStream = "/v1/stats/current/vhosts/%s/apps/%s/streams/%s" - ) type ResponseStats struct { - Message string `json:"message"` - StatusCode int `json:"statusCode"` - Data *ResponseStatsData `json:"response,omitempty"` + Message string `json:"message"` + StatusCode int `json:"statusCode"` + Data *ResponseStatsData `json:"response,omitempty"` } type ResponseStatsData struct { @@ -24,23 +23,22 @@ type ResponseStatsData struct { CreatedTime string `json:"createdTime" example:"2021-07-19T23:13:12.162+0200"` LastRecvTime string `json:"lastRecvTime" example:"2021-07-19T23:23:27.274+0200"` LastSentTime string `json:"lastSentTime" example:"2021-07-19T23:23:27.077+0200"` - LastUpdatedTime string `json:"lastUpdatedTime" example:"2021-07-19T23:23:27.274+0200"` + LastUpdatedTime string `json:"lastUpdatedTime" example:"2021-07-19T23:23:27.274+0200"` MaxTotalConnectionTime string `json:"maxTotalConnectionTime" example:"2021-07-19T23:16:37.851+0200"` // - coonnections - TotalConnections int `json:"totalConnections" example:"1"` - MaxTotalConnections int `json:"maxTotalConnections" example:"2"` + TotalConnections int `json:"totalConnections" example:"1"` + MaxTotalConnections int `json:"maxTotalConnections" example:"2"` // - traffic - TotalBytesIn uint64 `json:"totalBytesIn" example:"120197570"` - TotalBytesOut uint64 `json:"totalBytesOut" example:"117022184"` + TotalBytesIn uint64 `json:"totalBytesIn" example:"120197570"` + TotalBytesOut uint64 `json:"totalBytesOut" example:"117022184"` } - func (resp *ResponseStats) Log(log *log.Entry) { logger := log if resp.Data != nil { logger.WithFields(map[string]interface{}{ "max_clients": resp.Data.MaxTotalConnections, - "clients": resp.Data.TotalConnections, + "clients": resp.Data.TotalConnections, }) } logger.Info(resp.Message) @@ -48,7 +46,7 @@ func (resp *ResponseStats) Log(log *log.Entry) { func (c *configData) RequestStatsVHost(vhost string) (*ResponseStats, error) { req := ResponseStats{} 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 &req, nil @@ -57,7 +55,7 @@ func (c *configData) RequestStatsVHost(vhost string) (*ResponseStats, error) { func (c *configData) RequestStatsApp(vhost, app string) (*ResponseStats, error) { req := ResponseStats{} 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 &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) { req := ResponseStats{} 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 &req, nil