endpoints

package
v0.35.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleEndpoint

func HandleEndpoint(endpoint *LoadedEndpoint, w http.ResponseWriter, r *http.Request, params map[string]string, locals map[string]any) error

func Load

func Load(projectDir string) (map[string]*LoadedEndpoint, error)

Types

type Context

type Context struct {
	Request  *http.Request
	Response http.ResponseWriter
	Params   map[string]string
	Locals   map[string]any
}

func NewContext

func NewContext(w http.ResponseWriter, r *http.Request, params map[string]string, locals map[string]any) *Context

func (*Context) BindForm

func (c *Context) BindForm(v any) error

func (*Context) BindJSON

func (c *Context) BindJSON(v any) error

func (*Context) Cookie

func (c *Context) Cookie(name string) (*http.Cookie, error)

func (*Context) HTML

func (c *Context) HTML(status int, html string) error

func (*Context) Header

func (c *Context) Header(key string) string

func (*Context) JSON

func (c *Context) JSON(status int, data any) error

func (*Context) Param

func (c *Context) Param(key string) string

func (*Context) Query

func (c *Context) Query(key string) string

func (*Context) Redirect

func (c *Context) Redirect(url string, status int) error

func (*Context) Text

func (c *Context) Text(status int, text string) error

type EndpointCompiler

type EndpointCompiler struct {
	CacheDir   string
	BaseDir    string
	ModuleName string
	// contains filtered or unexported fields
}

func NewCompiler

func NewCompiler(baseDir, cacheDir string) *EndpointCompiler

func (*EndpointCompiler) Load

func (c *EndpointCompiler) Load(filePath string) (*LoadedEndpoint, error)

type HTTPMethod

type HTTPMethod string
const (
	GET     HTTPMethod = "GET"
	POST    HTTPMethod = "POST"
	PUT     HTTPMethod = "PUT"
	PATCH   HTTPMethod = "PATCH"
	DELETE  HTTPMethod = "DELETE"
	HEAD    HTTPMethod = "HEAD"
	OPTIONS HTTPMethod = "OPTIONS"
	ALL     HTTPMethod = "ALL"
)

type HandlerFunc

type HandlerFunc func(*Context) error

type LoadedEndpoint

type LoadedEndpoint struct {
	Handlers map[HTTPMethod]HandlerFunc
}

func LoadPlugin

func LoadPlugin(pluginPath string) (*LoadedEndpoint, error)

Jump to

Keyboard shortcuts

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