sprout

package module
v0.0.0-...-f997edf Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Sprout

TODO

Documentation

Index

Constants

View Source
const (
	ContextParamName = "_api_context"
)
View Source
const RequestContextEventName = "api.request.context"

Variables

View Source
var (
	GetCollectionOperation = OperationType{/* contains filtered or unexported fields */}
	GetOperation           = OperationType{/* contains filtered or unexported fields */}
	PostOperation          = OperationType{/* contains filtered or unexported fields */}
	PutOperation           = OperationType{/* contains filtered or unexported fields */}
	PatchOperation         = OperationType{/* contains filtered or unexported fields */}
	DeleteOperation        = OperationType{/* contains filtered or unexported fields */}
)

Functions

func NewFormatEventSubscriber

func NewFormatEventSubscriber(formatResolver FormatResolver) event.Subscriber

Types

type Context

type Context struct {
	Operation       *Operation
	RouteParameters RouteParameters
	QueryParameters QueryParameters
	Format          string
	Data            any
	Headers         http.Header
	StatusCode      int
}

type ContextFactory

type ContextFactory interface {
	CreateNew(operation *Operation) *Context
}

func NewContextFactory

func NewContextFactory() ContextFactory

type FormatResolver

type FormatResolver interface {
	Resolve(r *http.Request) (string, error)
}

func NewFormatResolver

func NewFormatResolver(mimeTypeProvider mime.MimeTypeProvider) FormatResolver

type Operation

type Operation struct {
	Name         string
	ResourceName string
	Type         OperationType
	UriTemplate  string
	Deserializer serialization.Deserializer
	Provider     state.Provider
	Processor    state.Processor
	Security     SecurityChecker
	StatusCode   int
}

type OperationHandler

type OperationHandler interface {
	Handle(w http.ResponseWriter, r *http.Request, c *Context) error
}

func NewDefaultOperationHandler

func NewDefaultOperationHandler() OperationHandler

func NewPostProcessingHandler

func NewPostProcessingHandler(uriFactory PostProcessingUriFactory) OperationHandler

func NewResponseContentTypeHandler

func NewResponseContentTypeHandler(formatProvider sharedMime.FormatProvider) OperationHandler

func NewResponseHandler

func NewResponseHandler() OperationHandler

type OperationType

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

func (OperationType) Method

func (ot OperationType) Method() string

type PostProcessingUriFactory

type PostProcessingUriFactory interface {
	Create(c *Context) (string, error)
}

type QueryParameters

type QueryParameters = any

type RequestContextEvent

type RequestContextEvent struct {
	*event.BasicEvent
	ResponseWriter http.ResponseWriter
	Request        *http.Request
	Context        *Context
}

func NewRequestContextEvent

func NewRequestContextEvent(w http.ResponseWriter, r *http.Request, ctx *Context) *RequestContextEvent

type RequestEvent

type RequestEvent struct {
	*event.BasicEvent
	ResponseWriter http.ResponseWriter
	Request        *http.Request
	Context        *Context
}

func NewRequestEvent

func NewRequestEvent(name string, w http.ResponseWriter, r *http.Request, ctx *Context) *RequestEvent

type ResponseEvent

type ResponseEvent struct {
	*event.BasicEvent
	ResponseWriter http.ResponseWriter
	Request        *http.Request
	Context        *Context
}

func NewResponseEvent

func NewResponseEvent(name string, w http.ResponseWriter, r *http.Request, c *Context) *ResponseEvent

type RouteParameters

type RouteParameters = map[string]string

type SecurityChecker

type SecurityChecker func(r *http.Request) bool

Directories

Path Synopsis
translation module
validation module

Jump to

Keyboard shortcuts

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