golem-add-http-endpoint-rust

Exposes Rust Golem agent methods as HTTP REST endpoints using code-first route definitions.

1.5k|212|Updated Nov 24, 2023
One-click install
npx skills add https://github.com/golemcloud/golem --skill golem-add-http-endpoint-rust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golem-add-http-endpoint-rust
Source: https://github.com/golemcloud/golem/tree/main/golem-skills/skills/rust/golem-add-http-endpoint-rust
Command: npx skills add https://github.com/golemcloud/golem --skill golem-add-http-endpoint-rust

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust Golem agents are not reachable over HTTP by default, so developers must manually wire up route definitions, mount paths, and deployment configuration to expose agent methods as a REST API.

Core Features & Use Cases

  • Code-First Route Definitions: Add a mount parameter to #[agent_definition] and annotate trait methods with #[endpoint(...)] to map HTTP methods and paths directly in Rust code.
  • Automatic Response Mapping: Return types like Option<T>, Result<T, E>, and UnstructuredBinary<M> map to appropriate HTTP status codes and JSON or binary bodies.
  • Phantom Agents: Enable phantom_agent = true to spawn a new agent instance per HTTP request for fully parallel processing.
  • Use Case: You have a TaskAgent written in Rust and want clients to call GET /task-agents/{name}/tasks over HTTP; this Skill walks you through the mount path, endpoint annotations, and the httpApi section in golem.yaml.

Quick Start

Ask the AI to expose your Rust Golem agent's methods as HTTP endpoints by adding a mount path and endpoint annotations, then updating golem.yaml with an httpApi deployment.

Frequently Asked Questions about golem-add-http-endpoint-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I expose a Golem Rust agent over HTTP?

Add a mount parameter to the #[agent_definition] attribute, annotate trait methods with #[endpoint(get = "/path")] or other HTTP methods, then add an httpApi deployment section to golem.yaml. Build and deploy to make the routes live.

How do HTTP return types map to status codes in Golem endpoints?

Unit returns 204 No Content, plain values return 200 OK with JSON, Option<T> returns 404 when None, and Result<T, E> returns 500 on Err. UnstructuredBinary<M> returns raw binary with a Content-Type header. This mapping is not configurable.

Can Golem endpoint paths use path variables and catch-all segments?

Yes, path variables in {braces} map to method parameters by exact name match. Catch-all {*name} variables are allowed only as the last path segment in endpoint paths, but they are not permitted in mount paths.

What is a phantom agent in Golem HTTP endpoints?

Setting phantom_agent = true on #[agent_definition] creates a new agent instance for each HTTP request instead of routing to a persistent instance. This enables fully parallel request processing without shared state between requests.

Why does my Golem endpoint fail when using custom types?

All custom types used in endpoint parameters or return values must derive the Schema trait from golem_rust. Without #[derive(Schema)], the agent cannot serialize or deserialize the type for HTTP requests and responses.