http

go
package api_test

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

Table-driven tests for HTTP handlers with httptest

go testing http
by Leah Thompson 1 tab
go
package retry

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

Retry on 429 with Retry-After parsing

go http client
by Leah Thompson 1 tab
typescript
import express, { Express, NextFunction, Request, Response } from 'express';
import { userRoutes } from './userRoutes';

function authenticate(req: Request, res: Response, next: NextFunction) {
  const header = req.header('authorization');
  if (!header || !header.startsWith('Bearer ')) {

Testing Express routes with Supertest + Jest

testing express supertest
by codesnips 4 tabs
go
package middleware

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

JWT verification with cached JWKS (handles key rotation)

go http security
by Leah Thompson 1 tab
ruby
require "faraday"
require "faraday/retry"

module Http
  class RetryableError < StandardError; end
  class CircuitOpenError < StandardError; end

HTTP Timeouts + Retries Wrapper (Faraday)

rails http reliability
by codesnips 3 tabs
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"

type StatusRecorder struct {
  http.ResponseWriter

Capture status code and bytes written via ResponseWriter wrapper

go http observability
by Leah Thompson 1 tab
go
package deps

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

Circuit breaker around flaky dependencies

go reliability circuit-breaker
by Leah Thompson 1 tab
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"
  "net/http"
  "net/netip"

CIDR allowlist middleware using netip (trust boundary explicit)

go http security
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
go
        package api

        import (
          "context"
          "crypto/rand"
          "encoding/hex"

HTTP handler with timeouts, request IDs, and context cancellation

go http context
by Leah Thompson 2 tabs