Skip to content
Back to skills

Api Endpoint Pattern

ASecurity

Standards for creating and organizing HTTP API endpoints using the Echo framework

  • 57 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 17, 2026
toolsgosqlapi

Works with

  • api

Security analysis

A100/100

Scanned October 17, 2026

npx -y skills add diegosouzapw/awesome-omni-skill --skill api-endpoint-pattern --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Api Endpoint Pattern?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Api Endpoint Pattern
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/diegosouzapw-api-endpoint-pattern/badge)](https://www.skillsdirectory.com/skills/diegosouzapw-api-endpoint-pattern)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: api-endpoint-pattern
description: Standards for creating and organizing HTTP API endpoints using the Echo framework
---

# API Endpoint Pattern Skill

Use this skill when adding or modifying HTTP endpoints in the API.

---

## Scope

- Creating new API endpoints
- Adding new domain routers
- Modifying handler logic

---

## Router Structure

### Main Router (`internal/router/router.go`)
Initializes Echo, sets up middleware, and groups routes by domain.

### Sub-Routers (`internal/router/[domain]/router.go`)
Each domain has its own sub-router with a `Bind` function that receives an `*echo.Group` and dependencies.

```go
func Bind(e *echo.Group, db *sql.DB) *echo.Group {
    e.GET("/list", func(c echo.Context) error {
        // handler logic
    })
    return e
}
```

---

## Adding a New Endpoint

1. If introducing a new domain, create `internal/router/[domain]/router.go`.
2. Implement a `Bind(e *echo.Group, db *sql.DB) *echo.Group` function.
3. Register the sub-router in `internal/router/router.go`:
   ```go
   domainrouter.Bind(api.Group("/domain"), config.DB.Conn)
   ```
4. Implement data access logic in `internal/models/` if needed.

---

## Handler Guidelines

- **Parameter Parsing**: Use helper functions for complex query params (e.g., trader levels).
- **Dependency Injection**: Pass `*sql.DB` into `Bind`, then into handlers. Avoid globals.
- **Response Handling**:
  - Success: `c.JSON(200, data)` or `c.String(200, "OK")`
  - Error: `c.String(code, err.Error())` — log significant errors with zerolog.
- **Business Logic**: Keep handlers thin. Move complex logic to `internal/models/` or other internal packages.

---

## Conventions

- Use `e.Group()` for logical route separation.
- Use plural names for collections (`/items`, `/weapons`).
- Use query parameters for filtering and optional configuration.
- Prefer HTTP status constants for consistency, but be consistent either way.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.