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 ¶
- func GetGroupProperty(g *SPLGroup, name string) object.Object
- func GetRequestProperty(req *SPLRequest, name string) object.Object
- func GetResponseProperty(res *SPLResponse, name string) object.Object
- func GetSSEWriterProperty(sse *SSEWriter, name string) object.Object
- func GetServerProperty(srv *SPLServer, name string) object.Object
- func GoToSPLObject(val any) object.Object
- func SPLObjectToGo(obj object.Object) any
- type SPLGroup
- type SPLRequest
- type SPLResponse
- type SPLServer
- type SSEWriter
- type TemplateRuntime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetGroupProperty ¶
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 ¶
GetSSEWriterProperty returns a property or method of the SSE writer.
func GetServerProperty ¶
GetServerProperty returns a property or method of the server object.
func GoToSPLObject ¶
GoToSPLObject converts a Go value (from JSON) to an SPL Object.
func SPLObjectToGo ¶
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) 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) 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) 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.