No description
|
Some checks failed
release / goreleaser (push) Failing after 3s
Co-Authored-By: Virgil <virgil@lethean.io> |
||
|---|---|---|
| .core | ||
| .github/workflows | ||
| ui | ||
| .gitignore | ||
| .goreleaser.yaml | ||
| CLAUDE.md | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| provider.go | ||
| README.md | ||
| static.go | ||
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
- Update
go.modmodule path - Rename
DemoProviderinprovider.go— implement your API - Rename
CoreDemoElementinui/src/index.ts— implement your UI - 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