dispatch

package
v0.0.0-...-b970022 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package dispatch is the pure-Go, CGO-free analogue of ActionDispatch's HTTP layer: a Request and Response wrapping the reused go-ruby-rack primitives, augmented with routing path parameters, a merged strong-parameters view, and content-type format negotiation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	*rack.Request
	// contains filtered or unexported fields
}

Request wraps a rack.Request, adding the path parameters produced by routing and the ActionController parameter/format accessors.

func NewRequest

func NewRequest(env rack.Env) *Request

NewRequest builds a dispatch Request over a Rack environment.

func (*Request) ActionName

func (r *Request) ActionName() string

ActionName returns the action resolved by routing, or "".

func (*Request) ControllerName

func (r *Request) ControllerName() string

ControllerName returns the controller resolved by routing, or "".

func (*Request) Format

func (r *Request) Format() string

Format returns the response format symbol negotiated for the request: the routing ":format" segment when present, otherwise the first recognised media type of the Accept header, defaulting to "html".

func (*Request) Parameters

func (r *Request) Parameters() (*parameters.Parameters, error)

Parameters returns the merged strong-parameters view: query parameters, overlaid by request-body parameters, overlaid by routing path parameters, exactly matching the precedence of ActionController's params.

func (*Request) PathParameters

func (r *Request) PathParameters() map[string]any

PathParameters returns a copy of the routing path parameters.

func (*Request) QueryParameters

func (r *Request) QueryParameters() (map[string]any, error)

QueryParameters returns the parsed query-string parameters as a plain map.

func (*Request) RequestParameters

func (r *Request) RequestParameters() (map[string]any, error)

RequestParameters returns the parsed POST/body parameters as a plain map.

func (*Request) SetPathParameters

func (r *Request) SetPathParameters(p map[string]any)

SetPathParameters stores the parameters recognized by the router (controller, action, and dynamic segments).

type Response

type Response struct {
	*rack.Response
}

Response wraps a rack.Response with ActionController conveniences. It starts as an empty 200 response; the embedded *rack.Response promotes Write, Status, SetStatus, Headers, SetContentType, SetLocation, and the rest of the Rack response API.

func NewResponse

func NewResponse() *Response

NewResponse returns an empty 200 response.

func (*Response) BodyString

func (r *Response) BodyString() string

BodyString returns the response body joined into a single string.

Jump to

Keyboard shortcuts

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