HTTP Request and Response Parameter Mapping (Scala)

SkillAI & models

Mapping HTTP request elements to Scala agent parameters. Use when the user asks about path variables, query parameters, header mapping, request body mapping, supported parameter types, or response type mapping for HTTP endpoints.

Available today. Use it from your connected AI after setup.

Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.

Then ask your AI: use the HTTP Request and Response Parameter Mapping (Scala) skill

What this skill tells your AI

The instructions your AI receives, as published by golemcloud/golem in golem-skills/skills/scala/golem-http-params-scala/SKILL.md and read by ahel’s review.

Overview

When an agent is exposed over HTTP, Golem maps parts of each HTTP request to constructor and method parameters. This skill covers how path segments, query parameters, headers, and request bodies are mapped, which types are supported for each, and how return types map to HTTP responses.

Path Variables

Path variables {varName} in mount or endpoint paths map to parameters by name:

// Mount path variables → constructor parameters (from class Id)
@agentDefinition(mount = "/api/tasks/{name}")
trait TaskAgent extends BaseAgent {
  class Id(val name: String)

  // Endpoint path variables → method parameters
  @endpoint(method = "GET", path = "/items/{itemId}")
  def getItem(itemId: String): Future[Item]
}

Remaining (catch-all) path variables capture everything after a prefix:

@endpoint(method = "GET", path = "/files/{*filePath}")
def getFile(filePath: String): Future[String]
// GET .../files/docs/readme.md → filePath = "docs/readme.md"

Catch-all variables can only appear as the last path segment and are not allowed in mount paths.

Query Parameters

Specified in the endpoint path using ?key={var} syntax:

@endpoint(method = "GET", path = "/search?q={query}&limit={n}")
def search(query: String, n: Int): Future[String]
// GET .../search?q=hello&limit=10

Header Variables

Map HTTP headers to parameters using the @header annotation on individual parameters:

import golem.runtime.annotations.header

@endpoint(method = "POST", path = "/report")
def submitReport(
  @header("X-Tenant") tenantId: String,
  data: String
): Future[String]

Supported Types for Path, Query, and Header Variables

Only these types can be used for parameters bound to path/query/header variables (the value is parsed from the URL/header string):

Scala TypeParsed From
StringUsed as-is
BooleanParsed from "true" / "false"
IntParsed as 32-bit signed integer
LongParsed as 64-bit signed integer
FloatParsed as 32-bit float
DoubleParsed as 64-bit float
Enum / sealed trait (unit cases only)Matched against known case names

For query parameters and headers only (not path variables), two additional wrapper types are supported:

Scala TypeBehavior
Option[T] (where T is a supported type above)Optional — absent query param or header produces None
List[T] / Array[T] (where T is a supported type above)Repeated query params or comma-separated header values

All other types (case classes, tuples, sealed traits with data, etc.) can only be used as body parameters.

POST Request Body Mapping

For POST/PUT/DELETE endpoints, method parameters not bound to path variables, query parameters, or headers are populated from the JSON request body:

@endpoint(method = "POST", path = "/items/{id}")
def updateItem(id: String, name: String, count: Int): Future[Item]
// POST .../items/123
// Body: { "name": "Widget", "count": 5 }
// → id from path, name and count from body

Each unmapped parameter becomes a top-level field in the expected JSON body object. All custom types require a zio.blocks.schema.Schema instance.

⚠️ Important: The request body is always a JSON object with parameter names as keys — even when there is only a single body parameter. For example, an endpoint def decide(decision: String) expects {"decision": "approved"}, never a bare string like "approved". Sending a non-object JSON value or plain text will fail with REQUEST_JSON_BODY_PARSING_FAILED.

Return Type to HTTP Response Mapping

Return TypeHTTP StatusResponse Body
Future[Unit]204 No Contentempty
Future[T]200 OKJSON-serialized T
Future[Option[T]]200 OK if Some, 404 Not Found if NoneJSON T or empty

Data Type to JSON Mapping

Scala TypeJSON Representation
StringJSON string
Int, LongJSON number (integer)
Float, DoubleJSON number (float)
BooleanJSON boolean
Array[T], List[T]JSON array
case class (with Schema)JSON object (camelCase field names)
Option[T]value or null
sealed trait / enumJSON variant
TupleJSON array

Related Skills

  • Load golem-add-http-endpoint-scala for the high-level workflow of defining and mounting HTTP endpoints on an agent

Signals

GitHub stars
2k
Forks
210
Last commit
Sep 2026
Advanced
Item type
skill
Key
golem-http-params-scala
Source
github.com/golemcloud/golem