model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package model holds the shared type definitions used by the code block evaluation pipeline: the Evaluator interface together with its request and result types, and the HTTP DTOs exchanged with the frontend.

Index

Constants

View Source
const (
	ContentTypeHTML = "text/html"
	ContentTypeText = "text/plain"
	ContentTypeJSON = "application/json"
)

Common content types returned by evaluators.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvalRequest

type EvalRequest struct {
	Language string            `json:"language"`
	Entry    string            `json:"entry,omitempty"`
	Files    map[string]string `json:"files"`
}

EvalRequest is the JSON request body for POST /api/codeblock/eval.

Language selects the evaluator (for example "php", "vuego", "exec", "sql"). Entry optionally overrides the default entry filename for the language. Files maps filename to content; for a single code fence this is usually a single entry, while @file references contribute additional companion files.

type EvalResponse

type EvalResponse struct {
	ContentType string `json:"contentType,omitempty"`
	Content     string `json:"content,omitempty"`
	Error       string `json:"error,omitempty"`
}

EvalResponse is the JSON response body for POST /api/codeblock/eval.

type Evaluator

type Evaluator interface {
	Eval(ctx context.Context, req Request) (Result, error)
}

Evaluator evaluates a code snippet built on top of an fs.FS. Implementations live in the internal/php, internal/vuego, internal/exec and internal/sqlite packages.

type Request

type Request struct {
	// FS holds all files available to the evaluation.
	FS fs.FS
	// Entry is the file within FS that should be evaluated.
	Entry string
}

Request is the input to an Evaluator. The caller is responsible for constructing an fs.FS containing every file required for the run and for nominating the entry point to evaluate (for example "index.php").

type Result

type Result struct {
	ContentType string
	Content     string
}

Result is the output of an Evaluator. ContentType lets the frontend decide how to render Content (HTML in an iframe, plain text in a <pre>, JSON as a table, and so on).

Jump to

Keyboard shortcuts

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