Skip to content

[Feature 03] API Server #22

@onlyhyde

Description

@onlyhyde

Overview

Implement HTTP API server using Echo framework with /verify and /settle endpoints.

Implementation Details

Files:

  • internal/api/server.go - Server setup
  • internal/api/handlers.go - Request handlers
  • internal/api/types.go - Request/Response types

Endpoints

Method Path Description
POST /verify Verify payment payload
POST /settle Execute settlement
GET /health Health check
GET /.well-known/x402-facilitator Discovery info

Request Types

VerifyRequest:

type VerifyRequest struct {
    Payload             json.RawMessage `json:"payload"`
    PaymentRequirements json.RawMessage `json:"paymentRequirements"`
}

SettleRequest:

type SettleRequest struct {
    Payload             json.RawMessage `json:"payload"`
    PaymentRequirements json.RawMessage `json:"paymentRequirements"`
}

Response Types

VerifyResponse:

type VerifyResponse struct {
    Valid   bool   `json:"valid"`
    Message string `json:"message,omitempty"`
}

SettleResponse:

type SettleResponse struct {
    Success bool   `json:"success"`
    TxHash  string `json:"txHash,omitempty"`
    Error   string `json:"error,omitempty"`
}

Acceptance Criteria

  • Echo server setup with middleware (Recover, RequestID, Logger)
  • POST /verify endpoint working
  • POST /settle endpoint working
  • GET /health endpoint
  • Request validation
  • Error handling with proper HTTP status codes
  • Unit tests for handlers
  • Integration tests

Dependencies

Branch

feature/api-server

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions