crud-handler-http

Enforce HTTP handler separation with DTO binding and service-layer business logic.

357|65|Updated Jul 29, 2022
One-click install
npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-handler-http
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: crud-handler-http
Source: https://github.com/ArtisanCloud/PowerX/tree/main/.codex/skills/crud/handler-http
Command: npx skills add https://github.com/ArtisanCloud/PowerX --skill crud-handler-http

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Handlers often mix business logic with IO; this skill enforces a strict separation by ensuring binding/validation stays in the HTTP handler and business logic runs in services.

Core Features & Use Cases

  • Bind/validate requests in the handler and delegate to service for processing.
  • Use DTOs and a unified error/response bridge to maintain consistent REST contracts across endpoints.
  • Support multi-tenant context via middleware, consistent pagination, and standard route registration under /api/v1/{admin|open|web}.

Quick Start

Implement the HTTP handler following the rules: bind/validate, call the service, and return a unified response envelope.

Frequently Asked Questions about crud-handler-http

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

FAQPage Schema
How do I separate HTTP request validation from business logic in my service layer?

To separate HTTP request validation from business logic, bind and validate DTOs directly in the HTTP handler, then delegate processing to the service layer. This ensures handlers avoid DB or IO operations, maintaining strict separation of concerns.

What's the best way to standardize REST API error handling and response envelopes?

Standardize REST API error handling by using a unified response and error bridge across endpoints. This approach maintains consistent REST contracts by mapping service layer errors to standardized HTTP responses.

How do I structure API routes for multi-tenant context with middleware?

Structure multi-tenant API routes by registering them in api.go with a /api/v1/admin|open|web prefix. Multi-tenant context is then supported through middleware, ensuring proper isolation and consistent pagination across requests.

Can I use dependency injection with HTTP handlers without coupling them to the database?

Yes, you can use dependency injection via *shared.Deps to provide necessary dependencies to HTTP handlers. This prevents handlers from directly accessing the DB or performing IO, keeping them focused on binding and validation.

Why should HTTP handlers avoid database and IO operations?

HTTP handlers should avoid database and IO operations to enforce strict separation of concerns. Keeping handlers limited to binding, validation, and delegation ensures business logic remains testable and isolated in the service layer.

When do I need DTO binding in HTTP handlers?

You need DTO binding in HTTP handlers when you want to validate incoming requests at the transport layer before passing them to the service layer. This ensures only properly formatted and validated data reaches your business logic.