web

package
v0.1.0-preview.4 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package web defines canonical descriptors for generated net/http adapters.

Index

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

func ControllerHandler(
	_ context.Context,
	invocation sdk.Invocation,
) (sdk.Result, error)

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

func GetHandler(
	_ context.Context,
	invocation sdk.Invocation,
) (sdk.Result, error)

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

func PostHandler(
	_ context.Context,
	invocation sdk.Invocation,
) (sdk.Result, error)

PostHandler contributes an HTTP POST route.

Types

This section is empty.

Jump to

Keyboard shortcuts

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