--- name: http_get_json kind: function lang: go domain: infra version: "1.0.0" purity: impure signature: "func HttpGetJSON(url string, headers map[string]string, timeout time.Duration) (map[string]any, error)" description: "GET request que espera JSON. Agrega Accept: application/json automaticamente. Retorna error con status code si >= 400. Siempre cierra body con defer." tags: [http, json, get, client, network, stdlib, infra, pendiente-usar, extractor] uses_functions: [] uses_types: [] returns: [] returns_optional: false error_type: "error_go_core" imports: ["encoding/json", "fmt", "io", "net/http", "time"] params: - name: url desc: "URL del endpoint HTTP a consultar" - name: headers desc: "mapa de headers custom a incluir en la solicitud" - name: timeout desc: "duracion maxima para completar la solicitud" output: "mapa con la estructura JSON decodificada del response" tested: true tests: - "httptest.Server con respuesta JSON" - "Status 404 → error" - "Timeout → error" - "Headers custom" test_file_path: "functions/infra/http_get_json_test.go" file_path: "functions/infra/http_get_json.go" --- ## Ejemplo ```go result, err := HttpGetJSON( "https://api.example.com/users", map[string]string{"X-Api-Key": "secret"}, 10*time.Second, ) if err != nil { return nil, err } fmt.Println(result["total"]) ``` ## Notas Solo usa stdlib (net/http, encoding/json). El timeout se configura en el http.Client. El error incluye los primeros 200 bytes del body para facilitar debugging. Los headers custom se fusionan con Accept: application/json (custom tiene precedencia).