go
package api

import (
  "encoding/json"
  "net/http"
)

WriteJSON helper with consistent headers and status

go http json
by Leah Thompson 1 tab
go
package api

import (
  "encoding/json"
  "errors"
  "io"

Strict JSON decode helper (size limit + unknown fields)

go http json
by Leah Thompson 1 tab
go
package middleware

import (
  "net/http"
  "sync/atomic"
)

Track in-flight requests with atomic counters

go observability concurrency
by Leah Thompson 1 tab
go
package api

import (
  "io"
  "net/http"
)

Content sniffing for uploads (don't trust the header)

go http uploads
by Leah Thompson 1 tab
go
package consumers

import (
  "context"

  "github.com/jackc/pgx/v5/pgxpool"

Idempotent event consumer with processed-events table

go postgres messaging
by Leah Thompson 1 tab
go
package observability

import (
  "expvar"
  "net/http"
)

expvar counters for quick-and-dirty production introspection

go observability metrics
by Leah Thompson 1 tab
go
package main

import (
  "os"
  "runtime/debug"
  "strconv"

Set a soft memory limit with debug.SetMemoryLimit

go performance memory
by Leah Thompson 1 tab
go
package pools

import (
  "bytes"
  "sync"
)

sync.Pool for bytes.Buffer to reduce allocations in hot paths

go performance memory
by Leah Thompson 1 tab
go
package cache

import (
  "context"

  "github.com/redis/go-redis/v9"

Redis Pub/Sub subscriber with reconnect-friendly loop

go redis pubsub
by Leah Thompson 1 tab
go
package store

import (
  "context"
  "database/sql"
)

sqlc transaction wrapper that keeps call sites clean

go sql postgres
by Leah Thompson 1 tab
go
package events

import "encoding/json"

type Envelope struct {
  Type    string          `json:"type"`

Store unstructured JSON safely with json.RawMessage

go json events
by Leah Thompson 1 tab
go
package api

import (
  "net/http"
  "strings"
)

Enforce JSON Content-Type and method early in handlers

go http api
by Leah Thompson 1 tab