Files
blog/tmp_client.go
T

23 lines
373 B
Go
Raw Normal View History

2026-06-01 17:57:22 +08:00
package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
resp, err := http.Get("http://localhost:8016/api/posts")
if err != nil {
fmt.Println("ERROR:", err)
os.Exit(1)
}
defer resp.Body.Close()
fmt.Println("Status:", resp.Status)
body, _ := io.ReadAll(resp.Body)
if len(body) > 500 {
body = body[:500]
}
fmt.Println("Body:", string(body))
}