agentleFS
jkanindajkaninda/okapi-skills/routing/SKILL.md

routing

Skill3 starsChanged 3 months agoMITView on GitHub

Generic registration: o.Handle(method, path, handler, ...opts). Both brace and colon syntax are accepted: Read them with c.PathParam("id") or c.Param("id"). Parameters declared in the path are auto-documented in OpenAPI. Type hints (:int, :uuid) affect OpenAPI schema generation only — at runtime every parameter is a string. A name of id or ending in _id is documented as a UUID by default. Inside a standard net/http handler use r.PathValue("id") or njia.Param(r, "id") — see the std_compat/ skill. HandleIO / HandleO write the…

13 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use parallelization and prompt-chaining.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • hajekimSkill

    parallelization

    This skill should be used when the user wants to "run tasks in parallel", "concurrent LLM calls", "fan-out and fan-in", "parallel agents", "simultaneous execution", "reduce latency with concurrency", "parallel sub-tasks", "parallel processing", "concurrent agent execution", "run agents simultaneously", "speed up with parallelism", "async agent execution", "batch LLM calls", "parallel workflow", "parallelize agent tasks", or needs to execute multiple independent tasks simultaneously. Also responds to Korean: "병렬 작업 실행", "동시 LLM 호출", "팬아웃 팬인 패턴", "병렬 에이전트", "동시 실행", "동시성으로 지연 시간 감소", "병렬로 실행", "동시에 여러 작업", "병렬 처리", "동시에 돌려줘", "빠르게 병렬로", "여러 작업 동시 실행해줘". Also responds to Japanese: "並列処理", "同時実行", "並列エージェント", "並行LLM呼び出し", "ファンアウト・ファンイン", "複数タスクを同時に実行したい", "処理速度を上げたい", "非同期エージェント", "バッチ処理", "並列で動かしたい" Also responds to Chinese: "并行处理", "并发执行", "并行智能体", "同时调用多个LLM", "扇出扇入模式", "多任务并行运行", "加快处理速度", "异步智能体", "批量LLM调用", "同时运行多个任务".. Apply this skill to design or implement the Parallelization agentic design pattern.

    Also in 3 projects that use this

  • hajekimSkill

    prompt-chaining

    This skill should be used when the user wants to "chain prompts", "build a pipeline", "break down complex tasks into steps", "sequential LLM calls", "multi-step reasoning", "pipeline pattern", "sequential agent pipeline", "multi-step prompt pipeline", "LLM chain", "step-by-step agent", "prompt pipeline", "decompose task into prompts", "stage-by-stage processing", "chained LLM calls", or when a task is too complex for a single prompt and needs to be decomposed into sequential sub-tasks. Also responds to Korean: "프롬프트 체이닝", "체인 방식 에이전트", "단계별 LLM 호출", "복잡한 작업 분해", "순차적 프롬프트 파이프라인", "단계적 작업 처리", "단계별 처리", "순차 처리 에이전트", "파이프라인 만들어줘", "단계적으로 처리해줘", "연속 프롬프트", "체이닝 해줘". Also responds to Japanese: "プロンプトチェーニング", "ステップごとに処理", "順次LLM呼び出し", "パイプライン構築", "複雑なタスクを分解", "段階的エージェント", "連続プロンプト", "LLMパイプライン", "順番に処理してほしい", "チェーン方式エージェント" Also responds to Chinese: "提示词链", "顺序调用LLM", "构建流水线", "分解复杂任务", "逐步处理", "链式提示", "多步骤流水线", "按顺序处理任务", "提示词管道", "帮我一步一步处理".. Apply this skill to design, implement, or explain the Prompt Chaining agentic design pattern.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

1 rule. 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 12 edited versions we read keep these.

  • 0

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read them with c.PathParam("id") or c.Param("id").

    line 29

“Common” is measured: kept by at least 6 in 10 of the 12 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Okapi Routing

HTTP Methods on *Okapi and *Group

Get(path, handler, ...RouteOption) *Route
Post(path, handler, ...RouteOption) *Route
Put(path, handler, ...RouteOption) *Route
Delete(path, handler, ...RouteOption) *Route
Patch(path, handler, ...RouteOption) *Route
Head(path, handler, ...RouteOption) *Route
Options(path, handler, ...RouteOption) *Route
Any(path, handler, ...RouteOption) *Route   // all methods — *Okapi only

Generic registration: o.Handle(method, path, handler, ...opts).

Path Parameters

Both brace and colon syntax are accepted:

/books/{id}          /books/:id          - string parameter
/books/{id:int}      /books/:id:int      - documented as integer
/books/{id:uuid}     /books/:id:uuid     - documented as UUID
/assets/{any...}                          - catch-all segment (matches the rest of the path)

Read them with c.PathParam("id") or c.Param("id"). Parameters declared in the path are auto-documented in OpenAPI.

Type hints (:int, :uuid) affect OpenAPI schema generation only — at runtime every parameter is a string. A name of id or ending in _id is documented as a UUID by default.

Inside a standard net/http handler use r.PathValue("id") or njia.Param(r, "id") — see the std_compat/ skill.

Standard Library Handlers

o.HandleStd(method, path, func(http.ResponseWriter, *http.Request), ...opts)  // http.HandlerFunc
o.HandleHTTP(method, path, http.Handler, ...opts)                             // http.Handler

// Both also exist on *Group and inherit the group prefix + middleware
api := o.Group("/api")
api.HandleStd("GET", "/legacy", legacyHandler)
api.HandleHTTP("GET", "/custom", &MyHandler{})

// Hand a whole subtree to an http.Handler with a catch-all
o.HandleHTTP("GET", "/assets/{any...}",
    http.StripPrefix("/assets/", http.FileServer(http.Dir("./public"))))

Generic Handler Wrappers

okapi.Handle[I](func(c *Context, in *I) error) HandlerFunc      // bind + validate input
okapi.H[I](func(c *Context, in *I) error) HandlerFunc           // shorthand for Handle
okapi.HandleIO[I, O](func(c *Context, in *I) (*O, error)) HandlerFunc // input + typed output
okapi.HandleO[O](func(c *Context) (*O, error)) HandlerFunc      // typed output only

HandleIO / HandleO write the response using content negotiation from the Accept header (JSON by default). See the validation/ skill for the full comparison.

Route Groups

group := o.Group("/api", middleware1, middleware2)
sub   := group.Group("/v1")            // nested; inherits the parent's middleware

group.WithTags([]string{"API"})                    // OpenAPI tags inherited by routes
group.WithTagInfo(okapi.GroupTag{                  // tag + description emitted at spec root
    Name:        "API",
    Description: "Public API",
    ExternalDocs: &okapi.ExternalDocs{URL: "https://docs.example.com"},
})
group.WithBearerAuth() / group.WithBasicAuth()     // auth scheme requirement in docs
group.WithSecurity([]map[string][]string{{"bearerAuth": {}}})
group.Deprecated()                                 // mark all routes deprecated
group.Disable() / group.Enable()                   // runtime toggle (all routes 404)
group.Use(...middleware)                           // add Okapi middleware
group.UseMiddleware(stdMiddleware)                 // add std-lib middleware
group.Register(routes ...RouteDefinition)          // bulk register
group.Okapi() *Okapi                               // back-reference

o.Group("") panics — a group needs a non-empty prefix.

Standalone construction: okapi.NewGroup("/api", o, middlewares...).

Route Methods

route.Hide() *Route                       // hide from OpenAPI docs (still serves traffic)
route.Deprecated() *Route                 // mark deprecated in docs
route.Disable() / route.Enable() *Route   // runtime enable/disable (404 when disabled)
route.Use(...Middleware)                  // per-route middleware
route.WithInput(req any) *Route           // request schema (bind + validate + document)
route.WithOutput(res any) *Route          // response schema
route.WithIO(req, res any) *Route         // both (either may be nil)
route.WithSecurity(...map[string][]string) *Route

Route exposes Name, Path, and Method fields.

Fallback Handlers

o.NoRoute(func(c *okapi.Context) error {  // 404 — path not matched
    return c.AbortNotFound("Custom 404 - Not found")
})

o.NoMethod(func(c *okapi.Context) error { // 405 — path matched, method not allowed
    return c.AbortMethodNotAllowed("Custom 405 - Method Not Allowed")
})

Trailing Slashes

o := okapi.New(okapi.WithStrictSlash(true)) // redirect /books/ -> /books

Static Files & SPA

o.Static("/assets", "public/assets")
o.StaticFile("/favicon.ico", "favicon.ico")
o.StaticFS("/assets", http.FS(embedFS))
o.Web("/", "./web")            // SPA with index fallback — register AFTER API routes
o.WebFS("/", dist, okapi.WebConfig{Root: "web/dist"})

Directory listing is disabled by default. Details in the web_spa/ skill.

Route Introspection

for _, r := range o.Routes() { // snapshot of []Route — mutating it does not affect the registry
    fmt.Println(r.Method, r.Path, r.Name)
}

Accessing Underlying Objects

o.Get("/raw", func(c *okapi.Context) error {
    req := c.Request()   // *http.Request
    w   := c.Response()  // okapi.ResponseWriter (extends http.ResponseWriter)
    w.Header().Set("X-Custom", "value")
    return nil
})

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.