golemcloud/golem/golem-add-http-endpoint-go
- community
Checking that the SKILL.md file is still in the repository.
Exposing a Go agent's methods over HTTP. Use when the user wants to add an HTTP endpoint/route to an agent, mount an agent under a URL path, make agent methods callable over HTTP, or map path/query/header parameters in a Go Golem project.
Install
npx vskill@latest install golemcloud/golem/golem-add-http-endpoint-goSKILL.md
Exposing a Go Agent over HTTP
Overview
HTTP mounting is metadata only: you declare, on the agent's definition, a URL prefix for the agent and a route for each method. The platform routes matching requests to the right instance and method — there is no incoming-request handler to write. To handle raw requests yourself (a net/http handler, streaming bodies, a website), use an HTTP router instead (see golem-http-router-go).
Two pieces, both on the definition:
Spec.HTTP = &golem.Mount{Path: "…"}— the agent-level prefix. Its{var}segments bind the agent's user-supplied constructor (ID) fields, so a request URL selects the instance. Every user-supplied `ID` field must appear as a `{var}`; exclude auto-injected `golem.Principal` fields.golem.HTTP(golem.GET("/suffix"), …)as a method option — one or more routes per method, with request data bound to the method's input fields.
Steps
- Add a mount to the agent's
Spec:HTTP: &golem.Mount{Path: "/counters/{name}"}. - Add routes to methods with the
golem.HTTP(...)option and a verb constructor. - Bind request data to input fields (path
{var},golem.Query,golem.Header, or the JSON body). - Build, then deploy behind an HTTP API so the routes are served.
Example (definition)
The handlers are ordinary handlers (see golem-add-agent-go) — nothing HTTP-specific in the impl.
Binding request data to input fields
- Path variables —
{sku}in a route suffix binds the input fieldSKU:golem.GET("/items/{sku}"). - Query parameters —
golem.Query("detailed", "detailed")binds?detailed=to theDetailedfield:
``go Lookup = Agent.Method[LookupIn, ItemInfo]("lookup", golem.HTTP(golem.GET("/items/{sku}", golem.Query("detailed", "detailed")))) ``
- Headers —
golem.Header("X-Tenant", "tenant")binds the header to theTenantfield. - Body — for body-carrying verbs (
POST/PUT), user-supplied input fields not bound to path/query/header come from the JSON request body. - Principal — the host injects
golem.Principalfields inIDand method inputs. Do not send them in the body or bind them to path/query/header; explicit principal bindings are rejected.
Auth & CORS
Mount{Auth: true}requires auth on every endpoint;golem.EndpointAuth(true|false)overrides it per route:
``go golem.HTTP(golem.GET("/items/{sku}", golem.EndpointAuth(true))) ``
Mount{CORS: []string{"*"}}sets allowed origins for the agent;golem.EndpointCORS(patterns...)adds patterns for one route.
Verbs
golem.GET, golem.POST, golem.PUT, golem.DELETE, and golem.Custom("VERB", "/path"). GET/HEAD are bodyless — bind all user-supplied inputs from path/query/header, excluding auto-injected golem.Principal.
Durable Stream Route Customization
A method that takes or returns golem.AgentStreams is served as a Durable Streams URL family. golem.DurableStreams customizes it:
- A slot is selected by exactly one of
Input(anAgentStreaminput field, by the same schema namegolem.Query/golem.Headerbind),Output(anAgentStreamfield of the returned struct) orResult: true(the returned value itself). Namechanges the public URL and OpenAPI name; the canonical name is no longer accepted.ContentTypeis allowed only for a directAgentStream[byte]slot and must be a concrete non-text, non-JSON MIME type without parameters or wildcards. Other streams stayapplication/json. SSE still usestext/event-streamwith base64 data.NoExternalWrites,NoStreamDeleteandNoInvocationDeleteremove that protocol operation (405with an exactAllowheader); leaving themfalsekeeps the operation.MaxReadersPerStreamis 1 through 16 and applies to long-poll and SSE.MaxAppendsPerSecondmust not be combined withNoExternalWrites. A limit rejection is429withRetry-After: 1; limits are per route and worker-service node, not cluster-wide.- A stream input cannot be bound from the path, query or a header.
Serving the Agent's Own Files
Mount.ExposeFiles serves files from the agent's filesystem under its mount, without calling a method:
- The agent must be durable and not a phantom, and every user-supplied
IDfield must be a scalar captured exactly once byMount.Path(no{*rest}), so a request names exactly one agent. Exclude auto-injectedgolem.Principalfields. - Mappings are tried in order; repeating a route with another path gives a fallback. A subtree route ends in
/*and its path in/$1. - Only
GETandHEADare served, with ranges and conditional requests. There is no directory listing, implicit index file or symlink following — expose only directories meant for HTTP. - Files the constructor or a method writes (with
os.WriteFile) are served as they change. Mount.FileResponseHeadersadds response headers, in order, to every file served:[]golem.FileResponseHeader{{Name: "content-security-policy", Value: "default-src 'none'"}}. Headers the platform manages itself (content-type,cache-control,etag, the CORS headers, …) are rejected at deploy.
Key Constraints
- Every user-supplied
IDfield must appear as a{var}inMount.Path(else the platform can't identify the instance), excluding auto-injectedgolem.Principal. Mount segments may be literals or named variables, but never a catch-all. A trailing{*rest}is allowed only in an endpoint suffix. - A method with an HTTP endpoint but no agent-level
Spec.HTTPmount is a definition error — set the mount. - Serving the routes requires an HTTP API deployment (see the manifest
httpApiconfiguration); mounting alone only advertises the routes.
Related Skills
| Skill | When to Load | |
|---|---|---|
golem-add-agent-go | Define the agent whose methods you're exposing | |
golem-make-http-request-go | Make an outgoing HTTP request from agent code | |
golem-multi-instance-agent-go | The {var} path segments select an instance by ID |
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinggolem-skills/skills/go/golem-add-http-endpoint-go/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/golemcloud/golem/golem-add-http-endpoint-go)