No description
Find a file
Snider 5143c211d3 feat: modernise template with core/go-api provider pattern
Replace Cobra CLI + raw net/http with core/go-api Engine.
DemoProvider implements RouteGroup for plug-and-play registration.
Lit element updated to fetch from Go API.
Add .core/build.yaml and CLAUDE.md.

Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-14 09:49:41 +00:00
.core feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
.github/workflows feat: Create template for custom HTML elements 2025-11-10 02:59:45 +00:00
ui feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
.gitignore feat: Create template for custom HTML elements 2025-11-10 02:59:45 +00:00
.goreleaser.yaml feat: Create template for custom HTML elements 2025-11-10 02:59:45 +00:00
CLAUDE.md feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
go.mod feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
go.sum feat: Create template for custom HTML elements 2025-11-10 02:59:45 +00:00
LICENSE Revise EUPL text for clarity and consistency 2025-11-12 14:19:20 +00:00
main.go feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
provider.go feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
README.md feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00
static.go feat: modernise template with core/go-api provider pattern 2026-03-14 09:49:41 +00:00

Core Element Template

Starter template for building custom HTML elements backed by a Go API. Part of the Core ecosystem.

Quick Start

# Clone and rename
git clone https://forge.lthn.ai/core/element-template.git my-element
cd my-element

# Install UI dependencies and build
cd ui && npm install && npm run build && cd ..

# Run
go run . --port 8080

Open http://localhost:8080 — you'll see the <core-demo-element> fetching data from the Go API.

What's Included

Component Technology Purpose
Go backend core/go-api (Gin) REST API with CORS, middleware
Custom element Lit 3 Self-contained web component
Build config .core/build.yaml Cross-platform binary builds

Making It Yours

  1. Update go.mod module path
  2. Rename DemoProvider in provider.go — implement your API
  3. Rename CoreDemoElement in ui/src/index.ts — implement your UI
  4. Update the element tag in ui/index.html

Service Provider Pattern

The DemoProvider implements api.RouteGroup:

func (p *DemoProvider) Name() string { return "demo" }
func (p *DemoProvider) BasePath() string { return "/api/v1/demo" }
func (p *DemoProvider) RegisterRoutes(rg *gin.RouterGroup) {
    rg.GET("/hello", p.hello)
}

Register it with engine.Register(&DemoProvider{}) and it gets middleware, CORS, and OpenAPI for free. The same provider can plug into core/ide's registry.

Licence

EUPL-1.2