apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: api-go-stdlib
  title: Go — stdlib net/http (lightweight)
  description: |
    Idiomatic Go HTTP service using stdlib `net/http` with the modern
    `ServeMux` (method matching, wildcards, `Request.PathValue()`).
    No third-party router needed for most APIs and services.
  tags:
    - go
    - lightweight-api
    - stdlib
  links:
    - url: https://pkg.go.dev/net/http
      title: net/http
    - url: https://go.dev/blog/routing-enhancements
      title: Routing enhancements in net/http (ServeMux)
    - url: https://go.dev/doc/modules/
      title: Go modules
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: net-http-servemux
        frontend:
          title: Frontend
          type: string
          const: api-only
        database:
          title: Database
          type: string
          enum:
            - postgres
            - sqlite
            - mysql
            - none
          enumNames:
            - 'Postgres — pgx driver'
            - 'SQLite — modernc.org/sqlite (pure Go) or mattn/go-sqlite3 (cgo)'
            - 'MySQL — go-sql-driver/mysql'
            - 'None — stateless service'
        persistence:
          title: Persistence Library
          type: string
          default: sqlx
          enum:
            - sqlx
            - sqlc
            - none
          enumNames:
            - 'sqlx — extensions over database/sql'
            - 'sqlc — generated typed code from SQL'
            - 'None — raw database/sql'
        background_jobs:
          title: Background Jobs
          type: string
          default: none
          enum:
            - none
            - asynq
            - river
          enumNames:
            - 'None'
            - 'Asynq — Redis-backed'
            - 'River — Postgres-backed'
        auth:
          title: Authentication
          type: string
          default: none
          enum:
            - none
            - jwt
          enumNames:
            - 'None'
            - 'JWT — golang-jwt/jwt middleware'
        observability:
          title: Observability
          type: string
          default: slog
          enum:
            - slog
            - opentelemetry
            - none
          enumNames:
            - 'log/slog — stdlib structured logging'
            - 'OpenTelemetry — slog + otel SDK'
            - 'None'
  tooling:
    package_manager: go-modules
    language_flavor: go
    test_runner: go-test
    lint_format: gofmt-go-vet-staticcheck
    runtime_cli: go
  smoke_test: |
    GET /health returns 200. One Go test uses net/http/httptest to
    invoke the handler and asserts the response status.
  switch_when: |
    Want Express-style chained middleware, FastHTTP performance,
    and a broad first-party middleware ecosystem → service-fiber
    (note: not net/http-compatible). For middleware composition
    that stays on net/http → consider Chi or Gin (future siblings).
