Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CreateTempFileError = newErrorCreator("Could not create temp file") DistDirAbsError = newErrorCreator("Could not get the absolute path of the dist directory") AppDirAbsError = newErrorCreator("Could not get the absolute path of the app directory") SrcDirAbsError = newErrorCreator("Could not get the absolute path of the src directory") IndexHtmlReadError = newErrorCreator("Could not read index.html") ServerEntryWriteError = newErrorCreator("Could not write server entry") CreateTempDirError = newErrorCreator("Could not create temp dir") CreateNodeJSVMError = newErrorCreator("Could not create Node.js VM") HashError = newErrorCreator("Could not hash") JSONMarshalError = newErrorCreator("Could not marshal JSON") JSONUnmarshalError = newErrorCreator("Could not unmarshal JSON") WriteFileError = newErrorCreator("Could not write file") ExecuteNodeJSCodeError = newErrorCreator("Could not execute Node.js code") InterfaceCastError = newErrorCreator("Could not cast interface") StartViteDevServerError = newErrorCreator("Could not start Vite dev server") )
Functions ¶
This section is empty.
Types ¶
type DevelopmentEngine ¶
type DevelopmentEngine struct {
// contains filtered or unexported fields
}
func (*DevelopmentEngine) Close ¶
func (e *DevelopmentEngine) Close() error
func (*DevelopmentEngine) Render ¶
func (e *DevelopmentEngine) Render(path string, props any) (*RenderResult, error)
func (*DevelopmentEngine) StaticPath ¶
func (e *DevelopmentEngine) StaticPath() string
type DevelopmentEngineOptions ¶
type DevelopmentEngineOptions struct { // The relative or absolute path to the directory of your vite project. // // **Default**: `.` AppDir string // Flags are the additional startup flags that are provided to the "node" // process. Flags []string // Port is the port to run the websocket server on. This defaults to 6543. Port int // ServerPort is the port of your Go HTTP server. ServerPort int // Stdout is the output writer for the VM. Default is os.Stdout. Stdout io.Writer // Stderr is the error writer for the VM. Default is os.Stderr. Stderr io.Writer // Env is the environment variables to be set for the VM. Env []string // Logger is the logger to be used for the VM. Logger *slog.Logger // contains filtered or unexported fields }
type Engine ¶
type Engine interface { // Render renders the given url with the given props. Render(url string, props any) (*RenderResult, error) // Close closes the engine. Close() error // StaticPath returns the path to the static directory. StaticPath() string }
func MustNewDevelopmentEngine ¶
func MustNewDevelopmentEngine(options DevelopmentEngineOptions) Engine
MustNewDevelopmentEngine is like New, but panics if an error occurs.
func MustNewProductionEngine ¶
func MustNewProductionEngine(options ProductionEngineOptions) Engine
MustNewProductionEngine is like New, but panics if an error occurs.
func NewDevelopmentEngine ¶
func NewDevelopmentEngine(options DevelopmentEngineOptions) (Engine, error)
NewDevelopmentEngine Creates a new Engine instance to be utilized in production. This will use the files built by vite to render the page HTML on the server.
func NewProductionEngine ¶
func NewProductionEngine(options ProductionEngineOptions) (Engine, error)
NewProductionEngine Creates a new Engine instance to be utilized in production. This will use the files built by vite to render the page HTML on the server.
type ErrorCreator ¶
type ErrorCreator struct {
// contains filtered or unexported fields
}
func (*ErrorCreator) Create ¶
func (ec *ErrorCreator) Create() error
func (*ErrorCreator) Format ¶
func (ec *ErrorCreator) Format(message string) error
func (*ErrorCreator) FormatErr ¶
func (ec *ErrorCreator) FormatErr(err error) error
func (*ErrorCreator) Is ¶
func (ec *ErrorCreator) Is(err error) bool
type ProductionEngine ¶
type ProductionEngine struct {
// contains filtered or unexported fields
}
func (*ProductionEngine) Close ¶
func (e *ProductionEngine) Close() error
func (*ProductionEngine) Render ¶
func (e *ProductionEngine) Render(url string, props any) (*RenderResult, error)
func (*ProductionEngine) StaticPath ¶
func (e *ProductionEngine) StaticPath() string
type ProductionEngineOptions ¶
type ProductionEngineOptions struct { // The relative or absolute path to the dist folder of your vite project. // // **Default**: `dist` DistDir string // Flags are the additional startup flags that are provided to the "node" // process. Flags []string // sort is the port to run the websocket server on. This defaults to 6543. Port int // Stdout is the output writer for the VM. Default is os.Stdout. Stdout io.Writer // Stderr is the error writer for the VM. Default is os.Stderr. Stderr io.Writer // Env is the environment variables to be set for the VM. Env []string // NodeProcesses is the number of node processes to run. Default is 5. NodeProcesses int // Logger is the logger to be used for the VM. Logger *slog.Logger }
Click to show internal directories.
Click to hide internal directories.