Item 1 of 15 of #168: "One request type instead of five". Built first; every item after it gets smaller with it.
Today (next at 989da78)
The same eight fields (source host, path and query; width, height, format, quality, fit) are declared as imgcache.ParsedURL (internal/imgcache/urlparser.go), imgcache.ImageRequest (internal/imgcache/imgcache.go), encurl.Payload, signature.Request and imageprocessor.Request. Size and FitMode are declared in both imgcache and imageprocessor, the output formats as imgcache.ImageFormat and imageprocessor.Format, and four conversions join them: ParsedURL.ToImageRequest, Payload.ToImageRequest, signatureRequest in internal/imgcache/service.go, and the literal in processAndStore. A reader following one request through pixa has to learn five shapes and four conversions.
Recommendation
One type, in one small package that imports no other package of this repo, holding the type, its constants, its validation, the parsing of the /v1/image/ path and the variant key function. signature, encurl, imageprocessor, imgcache and handlers import it. The type has two parts: what to fetch (host, path, query) and what to do to it (width, height, format, quality, fit). The processor takes only the second. This also settles the last item of #39: parsing moves with the type it produces, so no separate urlparser package is needed.
Names, taken from the proposals in #168 and recorded here as the choice: the package is internal/imagerequest; the two parts are the types Source and Transform; the format type is Format and the fit type Fit. Nothing else is renamed under this item.
Definition of done
internal/imagerequest holds the request type, Source, Transform, Format and Fit with their constants, the checks now in ValidateImageRequest, ValidateDimension and ValidateFitMode, the /v1/image/ path parsing now in internal/imgcache/urlparser.go, and the variant key function. It imports no other package of this repo, and its package comment says what it holds.
imgcache.ParsedURL, imgcache.ImageRequest, signature.Request, imageprocessor.Request, the second Size, the second fit type, the second format type and the four conversions are gone; every package uses the one type.
encurl keeps only a private struct carrying its short CBOR field names, converted to and from the one type inside encurl.
The processor's entry point takes a Transform only.
magic.ImageFormat stays; the item of #168 on deciding an input's format from its bytes once takes it.
Signature, Expires and AllowHTTP may stay on the request; the item of #168 that takes them off the request removes them.
Every URL of both image routes answers as before: same status, headers and bytes.
README.md and TODO.md name the new places wherever they name a moved type.
Approval and tests
sneak asked for each main recommendation of #168 to be its own issue, built before 1.0, one at a time in the order listed (#168 (comment)). That instruction is his approval of this item. Existing tests change only as this item needs: they follow code that moves or is renamed, and the tests of code this item removes go with it; no other assertion is weakened or dropped.
Model: opus-5-5
Item 1 of 15 of https://git.eeqj.de/sneak/pixa/issues/168: "One request type instead of five". Built first; every item after it gets smaller with it.
## Today (`next` at `989da78`)
The same eight fields (source host, path and query; width, height, format, quality, fit) are declared as `imgcache.ParsedURL` (`internal/imgcache/urlparser.go`), `imgcache.ImageRequest` (`internal/imgcache/imgcache.go`), `encurl.Payload`, `signature.Request` and `imageprocessor.Request`. `Size` and `FitMode` are declared in both `imgcache` and `imageprocessor`, the output formats as `imgcache.ImageFormat` and `imageprocessor.Format`, and four conversions join them: `ParsedURL.ToImageRequest`, `Payload.ToImageRequest`, `signatureRequest` in `internal/imgcache/service.go`, and the literal in `processAndStore`. A reader following one request through pixa has to learn five shapes and four conversions.
## Recommendation
One type, in one small package that imports no other package of this repo, holding the type, its constants, its validation, the parsing of the `/v1/image/` path and the variant key function. `signature`, `encurl`, `imageprocessor`, `imgcache` and `handlers` import it. The type has two parts: what to fetch (host, path, query) and what to do to it (width, height, format, quality, fit). The processor takes only the second. This also settles the last item of https://git.eeqj.de/sneak/pixa/issues/39: parsing moves with the type it produces, so no separate `urlparser` package is needed.
Names, taken from the proposals in https://git.eeqj.de/sneak/pixa/issues/168 and recorded here as the choice: the package is `internal/imagerequest`; the two parts are the types `Source` and `Transform`; the format type is `Format` and the fit type `Fit`. Nothing else is renamed under this item.
## Definition of done
- `internal/imagerequest` holds the request type, `Source`, `Transform`, `Format` and `Fit` with their constants, the checks now in `ValidateImageRequest`, `ValidateDimension` and `ValidateFitMode`, the `/v1/image/` path parsing now in `internal/imgcache/urlparser.go`, and the variant key function. It imports no other package of this repo, and its package comment says what it holds.
- `imgcache.ParsedURL`, `imgcache.ImageRequest`, `signature.Request`, `imageprocessor.Request`, the second `Size`, the second fit type, the second format type and the four conversions are gone; every package uses the one type.
- `encurl` keeps only a private struct carrying its short CBOR field names, converted to and from the one type inside `encurl`.
- The processor's entry point takes a `Transform` only.
- `magic.ImageFormat` stays; the item of https://git.eeqj.de/sneak/pixa/issues/168 on deciding an input's format from its bytes once takes it.
- `Signature`, `Expires` and `AllowHTTP` may stay on the request; the item of https://git.eeqj.de/sneak/pixa/issues/168 that takes them off the request removes them.
- Every URL of both image routes answers as before: same status, headers and bytes.
- `README.md` and `TODO.md` name the new places wherever they name a moved type.
## Approval and tests
sneak asked for each main recommendation of https://git.eeqj.de/sneak/pixa/issues/168 to be its own issue, built before 1.0, one at a time in the order listed (https://git.eeqj.de/sneak/pixa/issues/168#issuecomment-153513). That instruction is his approval of this item. Existing tests change only as this item needs: they follow code that moves or is renamed, and the tests of code this item removes go with it; no other assertion is weakened or dropped.
Model: opus-5-5
clawbot
added this to the 1.0.0 milestone 2026-10-21 12:48:50 +02:00
clawbot
self-assigned this 2026-10-21 12:48:50 +02:00
Built in #323, which targets next; its description says what changed and lists the judgement calls.
Model: opus-5-5
Built in https://git.eeqj.de/sneak/pixa/pulls/323, which targets `next`; its description says what changed and lists the judgement calls.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Item 1 of 15 of #168: "One request type instead of five". Built first; every item after it gets smaller with it.
Today (
nextat989da78)The same eight fields (source host, path and query; width, height, format, quality, fit) are declared as
imgcache.ParsedURL(internal/imgcache/urlparser.go),imgcache.ImageRequest(internal/imgcache/imgcache.go),encurl.Payload,signature.Requestandimageprocessor.Request.SizeandFitModeare declared in bothimgcacheandimageprocessor, the output formats asimgcache.ImageFormatandimageprocessor.Format, and four conversions join them:ParsedURL.ToImageRequest,Payload.ToImageRequest,signatureRequestininternal/imgcache/service.go, and the literal inprocessAndStore. A reader following one request through pixa has to learn five shapes and four conversions.Recommendation
One type, in one small package that imports no other package of this repo, holding the type, its constants, its validation, the parsing of the
/v1/image/path and the variant key function.signature,encurl,imageprocessor,imgcacheandhandlersimport it. The type has two parts: what to fetch (host, path, query) and what to do to it (width, height, format, quality, fit). The processor takes only the second. This also settles the last item of #39: parsing moves with the type it produces, so no separateurlparserpackage is needed.Names, taken from the proposals in #168 and recorded here as the choice: the package is
internal/imagerequest; the two parts are the typesSourceandTransform; the format type isFormatand the fit typeFit. Nothing else is renamed under this item.Definition of done
internal/imagerequestholds the request type,Source,Transform,FormatandFitwith their constants, the checks now inValidateImageRequest,ValidateDimensionandValidateFitMode, the/v1/image/path parsing now ininternal/imgcache/urlparser.go, and the variant key function. It imports no other package of this repo, and its package comment says what it holds.imgcache.ParsedURL,imgcache.ImageRequest,signature.Request,imageprocessor.Request, the secondSize, the second fit type, the second format type and the four conversions are gone; every package uses the one type.encurlkeeps only a private struct carrying its short CBOR field names, converted to and from the one type insideencurl.Transformonly.magic.ImageFormatstays; the item of #168 on deciding an input's format from its bytes once takes it.Signature,ExpiresandAllowHTTPmay stay on the request; the item of #168 that takes them off the request removes them.README.mdandTODO.mdname the new places wherever they name a moved type.Approval and tests
sneak asked for each main recommendation of #168 to be its own issue, built before 1.0, one at a time in the order listed (#168 (comment)). That instruction is his approval of this item. Existing tests change only as this item needs: they follow code that moves or is renamed, and the tests of code this item removes go with it; no other assertion is weakened or dropped.
Model: opus-5-5
Built in #323, which targets
next; its description says what changed and lists the judgement calls.Model: opus-5-5