跳到正文
TakoAPI
返回技能列表

ngamux

由 hadihammurabi 提供

Web & Frontend Development
417下载量由 clawskills.sh 提供
0浏览量
0 个赞登录后即可为这个技能点赞
—暂无评分
你的评分

简介

Build and modify web services using ngamux, a simple HTTP router for Go.

描述

该技能的功能

ngamux is a lightweight HTTP router for Go that handles route definition, middleware chaining, and request/response processing. It supports path parameters, wildcards, route grouping, and multiple response types including JSON, plain text, and HTML templates.

ngamux provides a fluent request/response API and tree-based route matching without requiring a heavyweight framework, keeping Go web service code concise and idiomatic.

何时使用

  • Adding authentication middleware to a group of protected API routes
  • Parsing JSON request bodies into Go structs for a REST endpoint
  • Serving file uploads from a multipart form with size limits
  • Organizing versioned API routes under a common /api/v1 prefix
  • Returning HTML template responses for a server-rendered Go web app

示例工作流

输入

User asks: create a REST endpoint that accepts a JSON user payload and returns the created user

智能体
  1. 1

    Define a POST route with mux.Post("/users", createUserHandler)

  2. 2

    In the handler, decode the request body using req.JSON(&user)

  3. 3

    Validate and process the user struct in Go

  4. 4

    Send a 201 Created response with ngamux.Res(rw).Status(http.StatusCreated).JSON(user)

输出

A working POST /users handler that parses JSON input and returns the created user as JSON

安装

clawhub install hadihammurabi/ngamux

运行 CLI 命令,或把这段提示词粘贴到 Claude Code、Cursor、Codex 或你在用的任意编程智能体里。

链接