5f4f1f7508
Añade campos params y output al frontmatter YAML de las 506 funciones del registry. Cada parámetro tiene descripción semántica (qué representa, unidades, rango típico) y cada función describe qué produce su output. Permite a agentes razonar sobre cadenas de composición (ej: prices → log_return → sharpe_ratio) sin leer código.
1.6 KiB
1.6 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| http_get_json | function | go | infra | 1.0.0 | impure | func HttpGetJSON(url string, headers map[string]string, timeout time.Duration) (map[string]any, error) | GET request que espera JSON. Agrega Accept: application/json automaticamente. Retorna error con status code si >= 400. Siempre cierra body con defer. |
|
false | error_go_core |
|
|
mapa con la estructura JSON decodificada del response | true |
|
functions/infra/http_get_json_test.go | functions/infra/http_get_json.go |
Ejemplo
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).