Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Releases: loadept/pirca

v1.3.0

Choose a tag to compare

@loadept loadept released this 26 May 01:35

v1.3.0 — Constrain keys store to string type

Summary

Changed the internal keys store from map[any]any to map[string]any, updating Set, Get and Delete to accept string keys instead of any.

Why

  • Gin alignment — Gin uses map[string]any with Set(string, any). Pirca is explicitly Gin-based, so matching this convention reduces cognitive overhead for users coming from Gin.
  • No real use case for any keys — In practice, every key in a request-scoped store is a string (user ID, role, claims, request ID, etc.). Non-string keys have no realistic application here.
  • Collision safety via namespacing — The any key type is useful in context.Context where typed keys prevent collisions across packages. But in a local request store, string keys with namespacing ("myapp.user", "mymod.role") achieve the same safely with less complexity.
  • Simplicity — Removing the any parameter type makes the API more self-documenting and eliminates an unnecessary abstraction.

Breaking Changes

  • Set(key any, value any)Set(key string, value any)
  • Get(key any)Get(key string)
  • Delete(key any)Delete(key string)

Migration is mechanical: pass a string as the key argument.

What we expect

This change should be transparent to almost all users since non-string keys were never a documented pattern. The API is now more idiomatic, easier to reason about, and consistent with Gin.

v1.2.0

Choose a tag to compare

@loadept loadept released this 26 May 00:54

v1.2.0

Features

  • GetBodyWith — new method that caches the raw request body on first read and returns it on subsequent calls without re-reading. Ideal for middlewares that need the raw body (HMAC verification, custom parsing, logging) while allowing downstream handlers to bind the cached body with BindJSONWith, BindXMLWith, etc.

Fixes

  • BindBodyWith — added nil body check, returns pirca: invalid request error when Request.Body is nil instead of panicking

Breaking Changes

None. Fully backward compatible.

v1.1.0

Choose a tag to compare

@loadept loadept released this 25 May 16:51

v1.1.0

Cambios

  • MIT License — licencia permisiva estándar para Go
  • Go 1.22 — máxima compatibilidad, ya no exige 1.26.3
  • READMEs actualizados — sección de requisitos

v1.0.1

Choose a tag to compare

@loadept loadept released this 24 May 18:47

v1.0.1

Bug fix: ctx.Request apuntaba al *Request incorrecto

ctx.Request se asignaba antes de r.WithContext(ctx), por lo que quedaba apuntando al *Request original en lugar del nuevo *Request que recibe el handler.

WithContext crea una shallow copy del request con un contexto distinto. Aunque los campos compartidos (URL, Header, Body, PathValue, etc.) funcionaban correctamente por ser la misma copia, la comparación ctx.Request == r devolvía false, lo que podía causar bugs en código que:

  • Comparara referencias de *Request
  • Almacenara ctx.Request esperando que fuera idéntico al r del handler
  • Inspeccionara la identidad del request entre middlewares

Cambio: ctx.Request ahora se asigna después de r.WithContext(ctx), usando el nuevo *Request que el handler recibe.

v1.0.0

Choose a tag to compare

@loadept loadept released this 24 May 18:03

Pirca v1.0.0

Middleware HTTP liviano para Go basado en Gin, con cero dependencias externas.

Características

  • Context enriquecido con binders JSON/XML, response writers, cookies, query params, forms, files
  • Cero dependencias — solo la stdlib de Go
  • Basado en Gin — misma lógica y patrones, sin framework
  • Implementa context.Context — pásalo directamente a bases de datos, HTTP clients, etc.
  • Captura status code y bytes escritos — ideal para logging y métricas
  • Key-value store — comparte datos entre middlewares y handlers
  • Control total — ctx.Request y ctx.Writer son los objetos originales de net/http

API

  • Body: Bind, BindJSON, BindJSONStrict, BindXML, BindBodyWith, BindJSONWith, BindJSONStrictWith, BindXMLWith, GetBodyBytes
  • Response: JSON, XML, String, Data, Redirect, File, FileFromFS, FileAttachment
  • Query: Query, DefaultQuery, GetQuery, QueryArray, GetQueryArray
  • Path: Param
  • Forms: FormValue, DefaultFormValue, GetFormValue
  • Files: FormFile, MultipartForm, SaveUploadedFile
  • Cookies: SetCookie, SetCookieData, Cookie, SetSameSite
  • Headers: Header, GetHeader
  • Status: Status, GetStatus, BytesWritten
  • Store: Set, Get, Delete
  • Context: Deadline, Done, Err, Value

Ver documentación completa en README.md