mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
A pattern never ends in "/" now, the root aside, because the router serves "/x" and "/x/" alike — so two spellings were two keys for one address, and a group could not name its own root at all: declaring "" on it produced the prefix with a trailing slash. That is why a collection root had to be declared at an absolute path on the parent instead, which put the route outside the middleware of the group it belonged to. The rule was also written twice. The router composed a prefix with a leaf and cmd/zipdoc composed the same two things to find that route's prose, so trimming in the router alone would have filed every collection root's sentence under an address the document does not contain — complete document, missing description, no error anywhere. Both copies are gone; internal/addr is the one that spells it. A test registers a trailing-slash pattern — the shape the Sentry-compatible ingest addresses use on purpose — and asserts the route table, the registry, the document's template, and the operation and concrete address a handler reads are all the same string, because a service that resolves its runtime handler by name from that pattern refuses every call if two of them disagree. Co-authored-by: Hanzo Dev <[email protected]>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
// Code generated by zipdoc; DO NOT EDIT.
|
|
|
|
package tables
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/zap-proto/zip"
|
|
)
|
|
|
|
func init() {
|
|
zip.Describe("github.com/zap-proto/zip/internal/zipdoc/testdata/tables POST /v1/items", zip.Doc{
|
|
Description: "Creates a new catalog item.",
|
|
Fields: map[string]string{
|
|
"ItemIn.name": "Name of the item.",
|
|
"ItemIn.price": "Price in cents.",
|
|
"ItemOut.id": "ID of the created item.",
|
|
"ItemOut.ok": "OK indicates status.",
|
|
},
|
|
Example: json.RawMessage(`{"name":"Widget","price":999}`),
|
|
Response: json.RawMessage(`{"id":"itm_1","ok":true}`),
|
|
})
|
|
zip.Describe("github.com/zap-proto/zip/internal/zipdoc/testdata/tables POST /v1/legacy/items", zip.Doc{
|
|
Description: "Creates a new catalog item via legacy registrar.",
|
|
Fields: map[string]string{
|
|
"ItemIn.name": "Name of the item.",
|
|
"ItemIn.price": "Price in cents.",
|
|
"ItemOut.id": "ID of the created item.",
|
|
"ItemOut.ok": "OK indicates status.",
|
|
},
|
|
Example: json.RawMessage(`{"name":"Widget","price":999}`),
|
|
Response: json.RawMessage(`{"id":"itm_1","ok":true}`),
|
|
})
|
|
}
|