auto(0129): agents_dashboard — secret_store_cpp_infra + CMakeLists register #4

Open
dataforge wants to merge 615 commits from auto/0129 into master
6 changed files with 115 additions and 0 deletions
Showing only changes of commit d8d72bb8d6 - Show all commits
+8
View File
@@ -0,0 +1,8 @@
package infra
// HTTPError representa un error HTTP estructurado para respuestas JSON.
type HTTPError struct {
Status int // codigo HTTP (ej: 400, 404, 500)
Code string // codigo de error legible por maquina (ej: "invalid_input")
Message string // mensaje de error legible por humano
}
+6
View File
@@ -0,0 +1,6 @@
package infra
import "net/http"
// Middleware es una funcion que envuelve un http.Handler para añadir comportamiento.
type Middleware func(http.Handler) http.Handler
+10
View File
@@ -0,0 +1,10 @@
package infra
import "net/http"
// Route define una ruta HTTP con metodo, path y handler.
type Route struct {
Method string // metodo HTTP (GET, POST, PUT, DELETE, PATCH, etc.)
Path string // path de la ruta (ej: /api/users/{id})
Handler http.Handler // handler que procesa la peticion
}
+32
View File
@@ -0,0 +1,32 @@
---
name: HTTPError
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: |
type HTTPError struct {
Status int
Code string
Message string
}
description: "Error HTTP estructurado para respuestas JSON. Combina status code HTTP, codigo de error legible por maquina y mensaje para el usuario."
tags: [http, error, server, json, infra]
uses_types: []
file_path: "functions/infra/http_error.go"
---
## Ejemplo
```go
err := HTTPError{
Status: 400,
Code: "invalid_input",
Message: "el campo email es requerido",
}
HTTPErrorResponse(w, err)
```
## Notas
Tipo producto — los tres campos son complementarios. Status es el codigo HTTP numerico que se usa en la respuesta. Code es un identificador maquina (snake_case) para el cliente. Message es texto libre legible por humanos. Se serializa a JSON con HTTPErrorResponse.
+28
View File
@@ -0,0 +1,28 @@
---
name: Middleware
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: "type Middleware func(http.Handler) http.Handler"
description: "Funcion que envuelve un http.Handler para añadir comportamiento (logging, auth, CORS, etc.)."
tags: [http, middleware, server, handler, infra]
uses_types: []
file_path: "functions/infra/http_middleware.go"
---
## Ejemplo
```go
// Middleware que añade un header a cada respuesta
func myMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("X-Custom", "value")
next.ServeHTTP(w, r)
})
}
```
## Notas
Tipo funcion — aplica el patron decorator sobre http.Handler. Se compone con HTTPMiddlewareChain para apilar comportamiento en orden. Cada Middleware recibe el siguiente handler y retorna un nuevo handler que puede modificar request y response.
+31
View File
@@ -0,0 +1,31 @@
---
name: Route
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: |
type Route struct {
Method string
Path string
Handler http.Handler
}
description: "Define una ruta HTTP con metodo, path y handler. Se usa con HTTPRouter para registrar rutas en un ServeMux."
tags: [http, route, server, router, infra]
uses_types: []
file_path: "functions/infra/http_route.go"
---
## Ejemplo
```go
routes := []Route{
{Method: "GET", Path: "/api/health", Handler: http.HandlerFunc(healthHandler)},
{Method: "POST", Path: "/api/users", Handler: http.HandlerFunc(createUserHandler)},
}
mux := HTTPRouter(routes)
```
## Notas
Tipo producto — los tres campos son obligatorios. Method debe ser un verbo HTTP valido en mayusculas. Path sigue la sintaxis del ServeMux de Go 1.22+ (soporta parametros como {id}). Handler puede ser cualquier http.Handler o http.HandlerFunc.