apps

package
v0.0.0-...-03a4827 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

README

Server Applications

The apps package contains app implementations that process HTTP requests.

Purpose

This package provides:

  1. App implementations (Echo, Script, MCP)
  2. App interface definition
  3. Map-based app storage by ID

Key Files

  • app.go: App interface definition
  • instances.go: Map wrapper for storing app instances by ID
  • {type}/config.go: Configuration structs for each app type
  • {type}/{type}.go: App implementation

App Interface

All apps implement two methods:

  • String() - Returns app ID
  • HandleHTTP() - Processes HTTP requests

Data Flow: Static data is embedded during app creation, not passed at runtime.

App Types

Currently implemented:

  • Echo: Returns request information for testing and debugging
  • Script: Executes scripts using Risor, Starlark, or WebAssembly engines
  • MCP: Executes Model Context Protocol tools and functions

Planned:

  • Composite: Chains multiple script apps in sequence

Usage

Apps are created during configuration validation and stored in an AppInstances map. The HTTP layer looks up apps by ID and calls their HandleHTTP() method to process requests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	// String returns the unique identifier of the application
	String() string

	// HandleHTTP processes HTTP requests for this application
	HandleHTTP(
		ctx context.Context,
		resp http.ResponseWriter,
		req *http.Request,
	) error
}

App defines the interface that all applications must implement. This interface defines what applications can do within the server context. Consumers (like HTTP layer) may define their own structurally identical interfaces.

type AppInstances

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

AppInstances is an immutable collection of application instances

func NewAppInstances

func NewAppInstances(apps []App) (*AppInstances, error)

NewAppInstances creates a new AppInstances from a slice of App instances

func (*AppInstances) All

func (c *AppInstances) All() iter.Seq[App]

All returns an iterator over all app instances in the collection. This enables clean iteration: for app := range instances.All() { ... }

func (*AppInstances) GetApp

func (c *AppInstances) GetApp(id string) (App, bool)

GetApp retrieves an application instance by ID

func (*AppInstances) String

func (c *AppInstances) String() string

String returns a string representation of the app instances

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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