go
package middleware

import (
  "compress/gzip"
  "net/http"
  "strings"

Gzip compression middleware with correct Vary header

go http middleware
by Leah Thompson 1 tab
go
package middleware

import (
  "net/http"

  "go.uber.org/zap"

Panic recovery middleware for HTTP servers

go http middleware
by Leah Thompson 1 tab
go
package domain

import (
  "errors"
  "fmt"
)

Error wrapping that stays inspectable with errors.Is and errors.As

go errors api
by Leah Thompson 1 tab
go
package health

import (
  "context"
  "net"
  "net/http"

Readiness and liveness probes with dependency checks

go http kubernetes
by Leah Thompson 1 tab
go
package paging

import (
  "encoding/base64"
  "encoding/json"
  "time"

Cursor pagination: opaque tokens with stable ordering

go api pagination
by Leah Thompson 1 tab
go
package cache

import (
  "context"
  "sync"
  "time"

Singleflight cache fill to prevent thundering herd

go cache concurrency
by Leah Thompson 1 tab
go
package deps

import (
  "net"
  "net/http"
  "time"

HTTP client tuned for production: timeouts, transport, and connection reuse

go http client
by Leah Thompson 1 tab
go
package store

import (
  "context"

  "github.com/jackc/pgx/v5"

Postgres transaction pattern with pgx: defer rollback, commit explicitly

go postgres pgx
by Leah Thompson 1 tab
go
package retry

import (
  "context"
  "math/rand"
  "time"

Exponential backoff with jitter for retries

go reliability retry
by Leah Thompson 1 tab
go
package deps

import (
  "context"
  "net/http"

Token bucket rate limiter for outbound calls

go rate-limit http
by Leah Thompson 1 tab
go
package pool

import "context"

type Job func(ctx context.Context) error

Bounded worker pool with backpressure

go concurrency worker-pool
by Leah Thompson 1 tab
go
package service

import (
  "context"

  "golang.org/x/sync/errgroup"

Fan-out with errgroup and shared cancellation

go concurrency context
by Leah Thompson 1 tab