server

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

pkg/server/server.go HTTP/HTTPS server implementation for Xxlang.

pkg/server/xhp.go XHP (Xxlang HTML Processor) implementation using Eval mode for segment-by-segment execution

Index

Constants

View Source
const (
	XHPStartTag = "<?xhp"
	XHPEndTag   = "?>"
)

XHP tag markers

View Source
const EndResponseMarker = "TX_END_RESPONSE_XT"

EndResponseMarker is returned by scripts to signal that the response is complete

Variables

This section is empty.

Functions

func CreateXHPInterpreter

func CreateXHPInterpreter(scriptPath string, res http.ResponseWriter, req *http.Request,
	paraMap map[string]string, globals map[string]interface{}) (*interpreter.Interpreter, error)

CreateXHPInterpreter creates an interpreter configured for XHP execution

func ExecuteXHPSegments

func ExecuteXHPSegments(segments []XHPSegment, interp *interpreter.Interpreter) (string, error)

ExecuteXHPSegments executes parsed XHP segments using Eval mode

func ProcessXHP

func ProcessXHP(content, scriptPath string, res http.ResponseWriter, req *http.Request,
	paraMap map[string]string, globals map[string]interface{}) (string, error)

ProcessXHP processes an XHP file using Eval mode for segment-by-segment execution XHP files contain HTML with <?xhp ... ?> code blocks that are executed All code blocks in the same XHP file share the same context (variables) return statements output their values, echo() function also outputs

func RunScriptOnHttp

func RunScriptOnHttp(code, scriptPath string, res http.ResponseWriter, req *http.Request,
	paraMap map[string]string, globals map[string]interface{}) (string, error)

RunScriptOnHttp executes Xxlang code for HTTP request

Types

type Config

type Config struct {
	HTTPPort  int    `json:"httpPort"`
	HTTPSPort int    `json:"httpsPort"`
	WebPath   string `json:"webPath"`
	MSPath    string `json:"msPath"`
	CertPath  string `json:"certPath"`
}

Config holds server configuration

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig loads server configuration from a JSON file

type Server

type Server struct {
	Config  Config
	Mux     *http.ServeMux
	Verbose bool
}

Server represents the HTTP/HTTPS server

func NewServer

func NewServer(cfg Config) *Server

NewServer creates a new server instance

func (*Server) Start

func (s *Server) Start() error

Start starts the HTTP and HTTPS servers

type XHPProcessor

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

XHPProcessor handles XHP template processing with Eval mode execution

func NewXHPProcessor

func NewXHPProcessor(scriptPath string, res http.ResponseWriter, req *http.Request,
	paraMap map[string]string, globals map[string]interface{}) *XHPProcessor

NewXHPProcessor creates a new XHP processor

func (*XHPProcessor) GetInterpreter

func (p *XHPProcessor) GetInterpreter() *interpreter.Interpreter

GetInterpreter returns the interpreter for direct access

func (*XHPProcessor) GetSymbolTable

func (p *XHPProcessor) GetSymbolTable() *compiler.SymbolTable

GetSymbolTable returns the symbol table for XHP processing

func (*XHPProcessor) Process

func (p *XHPProcessor) Process(content string) (string, error)

Process executes all segments and returns the final output

type XHPSegment

type XHPSegment struct {
	Type     XHPSegmentType // HTML or Code
	Content  string         // Raw content
	Position int            // Position in source
}

XHPSegment represents a parsed segment from XHP content

func ParseXHP

func ParseXHP(content string) ([]XHPSegment, error)

ParseXHP parses XHP content into segments

type XHPSegmentType

type XHPSegmentType int
const (
	XHPSegmentHTML XHPSegmentType = iota
	XHPSegmentCode
)

Jump to

Keyboard shortcuts

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