API Server

Standardize Golang HTTP services with routing, middleware, and graceful shutdown.

51|6|Updated Mar 28, 2019
One-click install
npx skills add https://github.com/Mte90/dotfiles --skill api-server
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: API Server
Source: https://github.com/Mte90/dotfiles/tree/main/.config/opencode/skills/golang/api-server
Command: npx skills add https://github.com/Mte90/dotfiles --skill api-server

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides a standardized approach to building reliable and maintainable HTTP services, REST APIs, and middleware in Golang, reducing boilerplate and promoting best practices.

Core Features & Use Cases

  • Standardized Routing: Offers guidance on choosing and implementing routers like net/http, Echo, or Gin.
  • Graceful Shutdown: Ensures applications handle termination signals correctly, preventing data loss.
  • Middleware Implementation: Details patterns for common middleware concerns like logging, authentication, and recovery.
  • Use Case: Develop a new microservice that exposes a REST API for user management, ensuring it can be gracefully shut down during deployments and includes essential middleware for logging and request tracing.

Quick Start

Use the API Server skill to create a new Golang HTTP service using the Echo framework with graceful shutdown implemented.

Frequently Asked Questions about API Server

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

FAQPage Schema
How do I implement graceful shutdown in a Golang HTTP server?

Middleware in a Golang REST API handles cross-cutting concerns like logging, authentication, and recovery. It allows you to process requests before they reach your main handlers, ensuring consistent application behavior across all endpoints.

How do I choose between net/http, Echo, and Gin for a Golang REST API?

Choosing between net/http, Echo, and Gin depends on your routing complexity and performance needs. Standardized routing guidance helps evaluate these frameworks to implement your Golang HTTP service effectively based on project requirements.

How do I separate Data Transfer Objects in a Golang HTTP service?

Data Transfer Object (DTO) separation in a Golang HTTP service isolates external API data structures from internal domain models. This practice enforces strict JSON content types for REST APIs and maintains clean, maintainable code boundaries.

Does this approach include health check endpoints for Golang microservices?

Yes, this standardized approach includes health check endpoints for Golang microservices. It enforces JSON content types for REST APIs and ensures your HTTP service exposes necessary endpoints for monitoring and orchestration platforms.

What is the best way to structure middleware for logging and request tracing in Golang?

The best way to structure middleware for logging and request tracing in Golang is using standardized patterns for cross-cutting concerns. This approach integrates seamlessly with your chosen router to provide consistent observability across all HTTP requests.