# Gateway Service

> Gateway Service Skill

- Skill: `mduongvandinh/gateway-service` (Agent Skill, multi-file: 8 files)
- Install (CLI): `npx skillmds@latest add mduongvandinh/gateway-service`
- Raw SKILL.md: https://api.skillmd.com/api/skills/mduongvandinh/gateway-service/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: mduongvandinh (https://skillmd.com/u/mduongvandinh)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/mduongvandinh/gateway-service

---

# Gateway Service Skill

## Service Type: API Gateway

Central entry point for all API requests.

## Responsibilities

- Request routing to backend services
- Authentication/Authorization (JWT validation)
- Rate limiting (Redis-based)
- Circuit breaker (Resilience4j)
- Request/Response logging
- CORS handling

## Package Structure

```
com.company.gateway/
├── config/         # Security, CORS configuration
├── filter/         # Global filters (logging, auth)
└── fallback/       # Circuit breaker fallbacks
```

## Key Components

### Route Configuration
Routes are defined in `application.yml`:
- Path-based routing
- Circuit breaker per service
- Rate limiting per endpoint

### Global Filters
- **LoggingFilter**: Logs all requests, adds trace ID
- **AuthFilter**: Validates JWT tokens (if needed)

### Fallback Controller
Returns friendly error messages when services are down.

## Adding New Route

```yaml
# application.yml
spring:
  cloud:
    gateway:
      routes:
        - id: new-service
          uri: http://localhost:808X
          predicates:
            - Path=/api/new/**
          filters:
            - name: CircuitBreaker
              args:
                name: newService
                fallbackUri: forward:/fallback/default
```

## Commands

```bash
# Run
mvn spring-boot:run

# Test routes
curl http://localhost:8080/api/users
curl http://localhost:8080/actuator/gateway/routes
```

