chore: auto-commit (57 archivos)
- frontend/functions/core/format_datetime_short.md - frontend/functions/core/format_datetime_short.test.ts - frontend/functions/core/format_datetime_short.ts - frontend/functions/core/format_duration.md - frontend/functions/core/format_duration.test.ts - frontend/functions/core/format_duration.ts - frontend/functions/core/month_grid.md - frontend/functions/core/month_grid.test.ts - frontend/functions/core/month_grid.ts - frontend/functions/core/string_hash_palette.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
---
|
||||
name: http_session_cookie_set
|
||||
kind: function
|
||||
lang: go
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "func SessionCookieSet(w http.ResponseWriter, name, token string, expiresAt int64)"
|
||||
description: "Escribe una cookie de sesion HttpOnly en la respuesta HTTP. Path='/', SameSite=Lax, Expires=time.Unix(expiresAt,0). No retorna error porque http.SetCookie no falla en runtime."
|
||||
tags: [http, session, cookie, auth, response]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: ["net/http", "time"]
|
||||
params:
|
||||
- name: w
|
||||
desc: "ResponseWriter donde se escribe el header Set-Cookie"
|
||||
- name: name
|
||||
desc: "nombre de la cookie (p.ej. 'kanban_session')"
|
||||
- name: token
|
||||
desc: "valor del token de sesion"
|
||||
- name: expiresAt
|
||||
desc: "timestamp Unix (segundos) de expiracion de la cookie"
|
||||
output: "escribe el header Set-Cookie en w; sin valor de retorno"
|
||||
tested: true
|
||||
tests:
|
||||
- "cookie set con nombre y token correctos"
|
||||
- "header Set-Cookie contiene HttpOnly y SameSite=Lax"
|
||||
test_file_path: "functions/infra/http_session_cookie_set_test.go"
|
||||
file_path: "functions/infra/http_session_cookie_set.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
sess, err := infra.SessionCreate(db, userID, 7*24*time.Hour, nil)
|
||||
if err != nil {
|
||||
http.Error(w, "internal error", 500)
|
||||
return
|
||||
}
|
||||
infra.SessionCookieSet(w, "my_session", sess.Token, sess.ExpiresAt)
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Extraido de apps/kanban/backend/auth.go. La funcion no retorna error porque `http.SetCookie` escribe directamente en los headers del ResponseWriter y nunca falla. El campo `error_type` se omite porque la firma no tiene retorno de error — hay precedente en el registry (componentes C++ y otros helpers HTTP impuros sin error_type).
|
||||
Reference in New Issue
Block a user