patch

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler wires HTTP decode/encode + auth.Mount for http.auth.user.patch.v1.

func NewHandler

func NewHandler(svc Service, policy auth.Policy) *Handler

NewHandler creates a Handler for http.auth.user.patch.v1.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux cell.RouteHandler) error

RegisterRoutes mounts the handler on mux via auth.Mount. Uses http.HandlerFunc(h.handle) so governance CH-04/CH-05 AST scans can resolve the handler function body via the Contract→Handler correlation.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler so *Handler can be used directly in tests and as an http.Handler argument without wrapping.

type Patch200JSONResponse

type Patch200JSONResponse Response

Patch200JSONResponse renders an HTTP 200 success response. Marshals the underlying Response DTO as a JSON body.

type Patch400ErrorResponse

type Patch400ErrorResponse struct {
	Body errcode.Error
}

Patch400ErrorResponse renders an HTTP 400 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type Patch401ErrorResponse

type Patch401ErrorResponse struct {
	Body errcode.Error
}

Patch401ErrorResponse renders an HTTP 401 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type Patch403ErrorResponse

type Patch403ErrorResponse struct {
	Body errcode.Error
}

Patch403ErrorResponse renders an HTTP 403 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type Patch404ErrorResponse

type Patch404ErrorResponse struct {
	Body errcode.Error
}

Patch404ErrorResponse renders an HTTP 404 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type Patch413ErrorResponse

type Patch413ErrorResponse struct {
	Body errcode.Error
}

Patch413ErrorResponse renders an HTTP 413 error response. Body carries an errcode.Error whose Kind/Code/Message/Details follow the canonical wire schema in contracts/shared/errors/error-response-v1.schema.json (5xx Details are stripped by Error.MarshalJSON; Internal never serializes).

type PatchResponseObject

type PatchResponseObject interface {
	// contains filtered or unexported methods
}

PatchResponseObject is the typed response envelope for http.auth.user.patch.v1. Service.Patch must return one of the Patch{Status}{Suffix} structs declared below; the generated handler dispatches via the unexported method, which keeps the implementation set closed to types declared in this package.

ref: oapi-codegen pkg/codegen/templates/strict/strict-responses.tmpl@main

(buffer-then-commit pattern: encode to bytes.Buffer first so encode
 failures don't commit a half-written response status to wire)

type Request

type Request struct {
	// format: uuid
	ID                   string `json:"id"`
	Name                 string `json:"name,omitempty"`
	Email                string `json:"email,omitempty"`
	Status               string `json:"status,omitempty"`
	RequirePasswordReset *bool  `json:"requirePasswordReset,omitempty"`
}

Request — http.auth.user.patch.v1.request

type Response

type Response struct {
	Data *ResponseData `json:"data"`
}

Response — http.auth.user.patch.v1.response

type ResponseData

type ResponseData struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Status   string `json:"status"`
	// format: date-time
	CreatedAt string `json:"createdAt"`
	// format: date-time
	UpdatedAt string `json:"updatedAt"`
}

ResponseData is a generated DTO for contract http.auth.user.patch.v1.

type Service

type Service interface {
	Patch(ctx context.Context, req *Request) (PatchResponseObject, error)
}

Service is the business interface that the http.auth.user.patch.v1 server cell must implement.

The signature follows the typed-response-envelope strict-server pattern (PR-V1-CONTRACT-TYPED-RESPONSE-ENVELOPE):

  • The Service implementation returns one of the generated typed Patch{Status}{Suffix} structs (each implements PatchResponseObject declared in types_gen.go). CH-04 governance enforces that this typed-response set matches contract.yaml http.responses[] declaration exactly.
  • The Go error return is reserved for *un-declared* framework 5xx situations (panics, infrastructure faults). The generated handler falls back to httputil.WriteError(err) on this path, which derives the response status from errcode.Kind (or returns 500 for non-errcode errors). Business 4xx / 5xx must be returned as a typed struct.

ref: oapi-codegen pkg/codegen/templates/strict/strict-interface.tmpl@main

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL