basic

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package basic provides a simple HTTP handler type for form-based request/response handling.

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 wraps a typed function and handles HTTP request decoding and response writing.

func NewHandler

func NewHandler(reqType RequestType, fn any) *Handler

NewHandler returns a Handler for the given request type and handler function.

func (*Handler) Error

func (*Handler) Error() rf.ErrorHandlerFunc

Error returns the rf.ErrorHandlerFunc for this handler.

func (*Handler) Handle

func (h *Handler) Handle() rf.HandlerFunc

Handle returns the rf.HandlerFunc for this handler.

type RequestType

type RequestType int

RequestType indicates how the handler should decode the incoming HTTP request.

const (
	// GetParams decodes the handler input from URL query parameters.
	GetParams RequestType = iota
	// PostForm decodes the handler input from a POST form body.
	PostForm
)

type Response

type Response struct {
	Body       string
	StatusCode int
	Headers    map[string]string
}

Response is returned by handler functions to control the HTTP response.

Jump to

Keyboard shortcuts

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