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.Handler

Context

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// HTMX detectionctx.IsHTMX() boolctx.HXTarget() stringctx.HXTrigger() stringctx.HXCurrentURL() string// 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// HTMX response headersctx.PushURL(url string)ctx.ReplaceURL(url string)ctx.Trigger(event string)ctx.TriggerAfterSettle(event string)ctx.TriggerAfterSwap(event string)ctx.Retarget(selector string)ctx.Reswap(strategy string)ctx.Refresh()

FragmentHandler

// Handler signaturetype FragmentHandler func(ctx *Context) (string, error)

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) string

pkg/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.Response

pkg/websocket

Hub

// Create hubhub := websocket.NewHub()// Run hub (in goroutine)go hub.Run()// Handle WebSocket upgradehub.HandleWebSocket(w http.ResponseWriter, r *http.Request, opts ...Option)// Broadcast to allhub.Broadcast(data []byte)// Broadcast to roomhub.BroadcastToRoom(room string, data []byte)// Send to sessionhub.SendToSession(sessionID string, data []byte)

Options

// Set roomwebsocket.WithRoom(room string)// Set message handlerwebsocket.WithMessageHandler(fn func(session *Session, msg []byte))

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

Response

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)

Next Steps