--- name: crud_get_handler kind: function lang: go domain: infra version: "1.0.0" purity: impure signature: "func CRUDGetHandler(res CRUDResource, db *sql.DB) http.HandlerFunc" description: "Genera un handler HTTP GET /{id} que busca un registro por id en la tabla del recurso y lo devuelve como JSON. Responde 404 si no existe o si soft_delete y tiene deleted_at no nulo." tags: [crud, get, handler, http, sqlite, infra] uses_functions: [http_json_response_go_infra, http_error_response_go_infra] uses_types: [CRUDResource_go_infra, HTTPError_go_infra] returns: [] returns_optional: false error_type: "error_go_core" imports: [database/sql, fmt, net/http] params: - name: res desc: "definicion del recurso" - name: db desc: "conexion *sql.DB a SQLite" output: "http.HandlerFunc que retorna el registro o 404" tested: true tests: ["devuelve el registro si existe", "responde 404 si no existe", "responde 404 si soft-deleted"] test_file_path: "functions/infra/crud_test.go" file_path: "functions/infra/crud_get_handler.go" --- ## Ejemplo ```go handler := CRUDGetHandler(res, db) mux.Handle("GET /api/projects/{id}", handler) // curl "localhost:8080/api/projects/abc-123" ``` ## Notas Impura. Usa r.PathValue("id") de Go 1.22+. El id es un string opaco (UUID en general). Si el recurso es SoftDelete y el registro tiene deleted_at no nulo, responde 404 como si no existiera.