Documentation
¶
Overview ¶
Package web defines canonical descriptors for generated net/http adapters.
Index ¶
- func Controller() sdk.Definition
- func ControllerHandler(_ context.Context, invocation sdk.Invocation) (sdk.Result, error)
- func Get() sdk.Definition
- func GetHandler(_ context.Context, invocation sdk.Invocation) (sdk.Result, error)
- func Post() sdk.Definition
- func PostHandler(_ context.Context, invocation sdk.Invocation) (sdk.Result, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Controller ¶
func Controller() sdk.Definition
Controller declares a constructible bean whose annotated methods are exposed through generated net/http adapters.
Spice validates and selects the controller constructor exactly as it does for a @Service. It then validates method signatures, request DTO bindings, response handling, authorization, and route conflicts before generating ordinary inspectable Go. Prefix is an optional absolute route path shared by the controller's methods.
// @import { Controller } from "github.com/spice-framework/spice/annotation/web"
// @Controller(prefix="/orders", constructor=NewHTTPController)
type HTTPController struct{}
func ControllerHandler ¶
ControllerHandler contributes generated net/http controller semantics.
func Get ¶
func Get() sdk.Definition
Get maps a controller method to an HTTP GET route.
Path is required, may be positional, and must be absolute. Spice validates path parameters against request DTO tags and generates content negotiation, validation, problem responses, and explicit response writing.
// @import { Get } from "github.com/spice-framework/spice/annotation/web"
// @Get("/orders/{id}")
func (*Controller) Find(context.Context, FindRequest) (Order, error)
func GetHandler ¶
GetHandler contributes an HTTP GET route.
func Post ¶
func Post() sdk.Definition
Post maps a controller method to an HTTP POST route.
Path is required, may be positional, and must be absolute. Request bodies use explicit DTO tags and bounded decoding; generated adapters return RFC 9457 problem responses for validation and application failures.
// @import { Post } from "github.com/spice-framework/spice/annotation/web"
// @Post("/orders")
func (*Controller) Create(context.Context, CreateRequest) (Order, error)
func PostHandler ¶
PostHandler contributes an HTTP POST route.
Types ¶
This section is empty.