Files
zineshop/tester.go
2025-03-24 01:04:01 +01:00

37 lines
535 B
Go

package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func testFunc() {
url := "http://localhost:8080/test"
method := "GET"
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Authorization", "Basic dXNlcjpwYXNzd29yZA==")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}