Code Explainers

Code explainers tagged #http-headers

javascript
import { NextResponse } from 'next/server'
 
const UPSTREAM = 'https://api.exchangerate.host/latest'
 

A cached exchange-rate proxy in Next.js

route-handler caching revalidation
Intermediate 7 steps
rust
use axum::{
    extract::Path,
    http::{header::ACCEPT, HeaderMap, StatusCode},
    response::{Html, IntoResponse, Json, Response},

Content negotiation in an Axum handler

content-negotiation http-headers serialization
Intermediate 8 steps
javascript
const crypto = require('crypto');
 
function securityHeaders(options = {}) {
  const {

A configurable security-headers middleware in Express

middleware http-headers content-security-policy
Intermediate 7 steps
rust
use std::time::Duration;
 
use axum::{
    http::{header, HeaderValue, Method},

Configuring CORS on an Axum Router

cors middleware http-headers
Intermediate 7 steps
javascript
const RATE_LIMIT = 100;
const WINDOW_MS = 60 * 1000;
const BLOCK_MS = 5 * 60 * 1000;
 

Building a rate-limiting middleware in Express

rate-limiting middleware closures
Intermediate 9 steps
rust
use axum::{
    body::Body,
    extract::Request,
    http::{header::HeaderValue, HeaderName},

Request ID middleware in Axum

middleware tracing request-extensions
Intermediate 7 steps
php
<?php
 
namespace App\Http\Middleware;
 

Enforcing a JSON Accept header in Laravel

middleware content-negotiation http-headers
Beginner 5 steps
rust
use axum::{
    body::Body,
    extract::Path,
    http::{header, StatusCode},

Streaming file downloads in Axum

streaming file-serving path-traversal
Intermediate 8 steps