You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

30 line
661 B

  1. package apiclient
  2. import (
  3. "fmt"
  4. "net/http"
  5. "strings"
  6. "github.com/AFASystems/presence/internal/pkg/config"
  7. )
  8. func setHeader(req *http.Request, token string) {
  9. req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
  10. }
  11. func getRequest(token, route string, client *http.Client, cfg *config.Config) (*http.Response, error) {
  12. url := fmt.Sprintf("%s/reslevis/%s", cfg.APIBaseURL, route)
  13. fmt.Printf("url: %s\n", url)
  14. req, err := http.NewRequest("GET", url, nil)
  15. if err != nil {
  16. return nil, err
  17. }
  18. setHeader(req, token)
  19. return client.Do(req)
  20. }
  21. func convertMac(mac string) string {
  22. return strings.ToUpper(strings.ReplaceAll(mac, ":", ""))
  23. }