@@ -62,7 +62,6 @@ type CacophonyAPI struct {
6262
6363// joinURL creates an absolute url with supplied baseURL, and all paths
6464func joinURL (baseURL string , paths ... string ) string {
65-
6665 u , err := url .Parse (baseURL )
6766 if err != nil {
6867 return ""
@@ -79,6 +78,7 @@ func (api *CacophonyAPI) getAPIURL() string {
7978func (api * CacophonyAPI ) getAuthURL () string {
8079 return joinURL (api .serverURL , authURL )
8180}
81+
8282func (api * CacophonyAPI ) getRegURL () string {
8383 return joinURL (api .serverURL , apiBasePath , regURL )
8484}
@@ -233,7 +233,6 @@ func (api *CacophonyAPI) authenticate() error {
233233 data ["groupname" ] = api .device .group
234234 }
235235 payload , err := json .Marshal (data )
236-
237236 if err != nil {
238237 return err
239238 }
@@ -294,7 +293,7 @@ func shaHash(r io.Reader) (string, error) {
294293func (api * CacophonyAPI ) UploadVideo (r io.Reader , data map [string ]interface {}) (int , error ) {
295294 buf := new (bytes.Buffer )
296295 w := multipart .NewWriter (buf )
297- //This will write to fileBytes as it reads r to get the sha hash
296+ // This will write to fileBytes as it reads r to get the sha hash
298297 var fileBytes bytes.Buffer
299298 tee := io .TeeReader (r , & fileBytes )
300299 hash , err := shaHash (tee )
@@ -311,7 +310,6 @@ func (api *CacophonyAPI) UploadVideo(r io.Reader, data map[string]interface{}) (
311310
312311 // JSON encoded "data" parameter.
313312 dataBuf , err := json .Marshal (data )
314-
315313 if err != nil {
316314 return 0 , err
317315 }
@@ -519,7 +517,7 @@ func handleHTTPResponse(resp *http.Response) error {
519517 return nil
520518}
521519
522- //formatTimestamp to time.RFC3339Nano format
520+ // formatTimestamp to time.RFC3339Nano format
523521func formatTimestamp (t time.Time ) string {
524522 return t .UTC ().Format (time .RFC3339Nano )
525523}
@@ -539,7 +537,7 @@ func (api *CacophonyAPI) GetSchedule() ([]byte, error) {
539537 return nil , err
540538 }
541539 req .Header .Set ("Authorization" , api .token )
542- //client := new(http.Client)
540+ // client := new(http.Client)
543541
544542 resp , err := api .httpClient .Do (req )
545543 if err != nil {
@@ -562,7 +560,6 @@ func (api *CacophonyAPI) ReRegisterByAuthorized(newName, newGroup, newPassword,
562560 if err != nil {
563561 return err
564562 }
565- log .Println ("jsonAll" , string (jsonAll ))
566563 url := joinURL (api .serverURL , apiBasePath , "devices/reregister-authorized" )
567564 req , err := http .NewRequest ("POST" , url , bytes .NewReader (jsonAll ))
568565 if err != nil {
@@ -589,8 +586,6 @@ func (api *CacophonyAPI) ReRegisterByAuthorized(newName, newGroup, newPassword,
589586 name : newName ,
590587 password : newPassword ,
591588 }
592- log .Println ("respData.Token" , respData .Token )
593- log .Println ("respData.ID" , respData .ID )
594589
595590 api .token = respData .Token
596591 api .device .password = newPassword
0 commit comments