server

package
v0.0.0-...-182b3b8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Overview

Package server provides the SPL http server/router builtins, backed by github.com/oarkflow/fh instead of net/http. It supports global middleware, path-scoped middleware, per-route middleware chains, and nested route groups with group-level middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGroupProperty

func GetGroupProperty(g *SPLGroup, name string) object.Object

GetGroupProperty returns a property or method of the route group object.

func GetRequestProperty

func GetRequestProperty(req *SPLRequest, name string) object.Object

GetRequestProperty returns a property or method of the request object.

func GetResponseProperty

func GetResponseProperty(res *SPLResponse, name string) object.Object

GetResponseProperty returns a property or method of the response object.

func GetSSEWriterProperty

func GetSSEWriterProperty(sse *SSEWriter, name string) object.Object

GetSSEWriterProperty returns a property or method of the SSE writer.

func GetServerProperty

func GetServerProperty(srv *SPLServer, name string) object.Object

GetServerProperty returns a property or method of the server object.

func GoToSPLObject

func GoToSPLObject(val any) object.Object

GoToSPLObject converts a Go value (from JSON) to an SPL Object.

func SPLObjectToGo

func SPLObjectToGo(obj object.Object) any

SPLObjectToGo converts an SPL Object to a Go value for JSON marshaling.

Types

type SPLGroup

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

SPLGroup is a route group: a shared path prefix plus an ordered list of group-level middlewares prepended to every route registered through it. Nested groups accumulate their parent's middlewares.

func (*SPLGroup) Inspect

func (g *SPLGroup) Inspect() string

func (*SPLGroup) Type

func (g *SPLGroup) Type() object.ObjectType

type SPLRequest

type SPLRequest struct {
	Method  string
	Path    string
	Params  map[string]string
	Query   map[string][]string
	Headers map[string][]string
	Body    string
	Ctx     fh.Ctx
}

func (*SPLRequest) Inspect

func (r *SPLRequest) Inspect() string

func (*SPLRequest) Type

func (r *SPLRequest) Type() object.ObjectType

type SPLResponse

type SPLResponse struct {
	Ctx        fh.Ctx
	Server     *SPLServer
	StatusCode int
	// contains filtered or unexported fields
}

func (*SPLResponse) Inspect

func (r *SPLResponse) Inspect() string

func (*SPLResponse) Type

func (r *SPLResponse) Type() object.ObjectType

type SPLServer

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

func (*SPLServer) Inspect

func (s *SPLServer) Inspect() string

func (*SPLServer) Type

func (s *SPLServer) Type() object.ObjectType

type SSEWriter

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

SSEWriter hijacks the underlying connection so events can be pushed to the client at arbitrary times from SPL code, independent of fh's normal per-request response lifecycle.

func (*SSEWriter) Inspect

func (s *SSEWriter) Inspect() string

func (*SSEWriter) Type

func (s *SSEWriter) Type() object.ObjectType

type TemplateRuntime

type TemplateRuntime interface {
	Render(tmpl string, data map[string]any) (string, error)
	RenderFile(path string, data map[string]any) (string, error)
	RenderSSR(tmpl string, data map[string]any) (string, error)
	RenderSSRFile(path string, data map[string]any) (string, error)
	RenderStream(w io.Writer, tmpl string, data map[string]any) error
	RenderStreamFile(w io.Writer, path string, data map[string]any) error
	InvalidateCaches()
}

TemplateRuntime is the interface for server-side template rendering.

Jump to

Keyboard shortcuts

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