API Reference
Complete API reference for irgo packages.
pkg/router
Router
// Create new routerr := router.New()// HTTP methodsr.GET(path string, handler FragmentHandler)r.POST(path string, handler FragmentHandler)r.PUT(path string, handler FragmentHandler)r.DELETE(path string, handler FragmentHandler)r.PATCH(path string, handler FragmentHandler)// Route groupsr.Route(pattern string, fn func(r *Router))// Static filesr.Static(path string, root http.FileSystem)// Middlewarer.Use(middleware ...func(http.Handler) http.Handler)// Get http.Handlerr.Handler() http.HandlerContext
type Context struct { Request *http.Request ResponseWriter http.ResponseWriter}// Inputctx.Param(key string) stringctx.Query(key string) stringctx.FormValue(key string) stringctx.Header(key string) string// Datastar detection & signalsctx.IsDatastar() boolctx.ReadSignals(v any) errorctx.SSE() *datastar.SSE// HTML responsesctx.HTML(html string) errorctx.HTMLStatus(status int, html string) error// JSON responsesctx.JSON(data any) errorctx.JSONStatus(status int, data any) error// Errorsctx.Error(err error) errorctx.ErrorStatus(status int, msg string) errorctx.NotFound(msg string) errorctx.BadRequest(msg string) errorctx.Unauthorized(msg string) errorctx.Forbidden(msg string) error// Redirectsctx.Redirect(url string) error// No contentctx.NoContent() error// SSE response methods (via ctx.SSE())sse.PatchTempl(c templ.Component) errorsse.PatchElements(id string, html string) errorsse.PatchSignals(signals map[string]any) errorsse.RemoveElements(selector string) errorsse.Redirect(url string) errorsse.Console(level string, msg string) errorHandler Types
// Page handler (full page renders)type PageHandler func(ctx *Context) (string, error)// Datastar handler (SSE responses)type DatastarHandler func(ctx *Context) error// Register Datastar handlersr.DSGet(path string, handler DatastarHandler)r.DSPost(path string, handler DatastarHandler)r.DSPut(path string, handler DatastarHandler)r.DSPatch(path string, handler DatastarHandler)r.DSDelete(path string, handler DatastarHandler)pkg/render
TemplRenderer
// Create rendererrenderer := render.NewTemplRenderer()// Render templ component to stringhtml, err := renderer.Render(component templ.Component) (string, error)pkg/desktop
Config
type Config struct { Title string // Window title Width int // Window width Height int // Window height Resizable bool // Allow resize Debug bool // Enable devtools Port int // Server port (0 = auto)}// Default configurationconfig := desktop.DefaultConfig()App
// Create desktop appapp := desktop.New(handler http.Handler, config Config)// Run (blocks until window closed)err := app.Run()Utilities
// Find static files directorydir := desktop.FindStaticDir() string// Find resource pathpath := desktop.FindResourcePath(name string) stringpkg/mobile
Bridge
// Initialize mobile bridgemobile.Initialize()// Set HTTP handlermobile.SetHandler(handler http.Handler)pkg/adapter
HTTPAdapter
// Create adapter for virtual HTTPadapter := adapter.NewHTTPAdapter(handler http.Handler)// Handle request (called from native code)response := adapter.HandleRequest(request *core.Request) *core.Responsepkg/datastar
SSE
// Create SSE writersse := datastar.NewSSE(w http.ResponseWriter, r *http.Request)// Patch templ component into DOMsse.PatchTempl(c templ.Component) error// Patch raw HTML into elementsse.PatchElements(id string, html string) error// Update client-side signalssse.PatchSignals(signals map[string]any) error// Remove elements from DOMsse.RemoveElements(selector string) error// Redirect to URLsse.Redirect(url string) error// Log to browser consolesse.Console(level string, msg string) errorHub (Server Push)
// Create hubhub := datastar.NewHub()// Run hub (in goroutine)go hub.Run()// Handle SSE connectionshub.HandleSSE(w http.ResponseWriter, r *http.Request, opts ...Option)// Broadcast to allhub.Broadcast(events ...datastar.Event)// Broadcast to roomhub.BroadcastToRoom(room string, events ...datastar.Event)// Send to sessionhub.SendToSession(sessionID string, events ...datastar.Event)Options
// Set roomdatastar.WithRoom(room string)// Set session IDdatastar.WithSessionID(id string)pkg/testing
Client
// Create test clientclient := testing.NewClient(handler http.Handler)// HTTP methodsclient.Get(path string) *Responseclient.GetWithHeaders(path string, headers map[string]string) *Responseclient.PostForm(path string, data map[string]string) *Responseclient.PostJSON(path string, data any) *Responseclient.Put(path string, data map[string]string) *Responseclient.Patch(path string, data map[string]string) *Responseclient.Delete(path string) *Response// Datastar testingclient.Datastar() *Client // Returns client with Datastar headersResponse
type Response struct { StatusCode int Headers http.Header}// Get bodyresp.Body() string// Assertionsresp.AssertOK(t *testing.T)resp.AssertStatus(t *testing.T, status int)resp.AssertRedirect(t *testing.T, url string)resp.AssertContains(t *testing.T, text string)resp.AssertNotContains(t *testing.T, text string)resp.AssertHeader(t *testing.T, key, value string)// SSE assertionsresp.AssertSSEEvent(t *testing.T, eventType string)resp.ParseSSEEvents() []SSEEventNext Steps
- Routing & Handlers - Usage examples
- Templ Templates - Template syntax
- GitHub - Source code
