Add requests package and implement JSON fetching in main.go

This commit is contained in:
2025-05-25 00:52:31 +03:00
parent 9aaefaa72b
commit 53a739e5d2
20 changed files with 22 additions and 1 deletions

16
cmd/server/main.go Normal file → Executable file
View File

@@ -4,6 +4,7 @@ import (
adapters2 "Sipro-Marketplaces/internal/test/adapters"
"context"
"database/sql"
"github.com/carlmjohnson/requests"
"log"
"os"
"os/signal"
@@ -91,6 +92,21 @@ func (s *Server) shutdown() {
}
func main() {
type post struct {
Name string `json:"name"`
Language string `json:"language"`
ID string `json:"id"`
Bio string `json:"bio"`
Version float64 `json:"version"`
}
response := new([]post)
err := requests.URL("https://microsoftedge.github.io/Demos/json-dummy-data/5MB-min.json").ToJSON(&response).Fetch(context.Background())
if err != nil {
log.Fatalf("Failed to fetch URL: %v", err)
}
println(len(*response))
return
cfg := config.Load()
server, err := NewServer(cfg)
if err != nil {