Code Explainers
Code explainers tagged #middleware
python
import time from collections import defaultdict from threading import Lock
Sliding-window login rate limiting in Flask
rate-limiting
sliding-window
thread-safety
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 std::net::SocketAddr; use std::time::Duration; use axum::{routing::get, Json, Router};
Per-IP rate limiting in Axum with tower-governor
rate-limiting
middleware
tower
Intermediate
7 steps
go
package handlers import ( "net/http"
Cookie-based sessions in Gin
authentication
cookies
middleware
Intermediate
7 steps
rust
use axum::{ body::Body, extract::Request, http::{header::HeaderValue, HeaderName},
Request ID middleware in Axum
middleware
tracing
request-extensions
Intermediate
7 steps
go
package webhooks import ( "crypto/hmac"
Verifying GitHub webhooks in Gin
hmac
webhooks
middleware
Intermediate
6 steps
go
package middleware import ( "errors"
Centralized error handling in Gin
middleware
error-handling
custom-errors
Intermediate
8 steps
rust
use axum::{ extract::FromRequestParts, http::{request::Parts, StatusCode, header::AUTHORIZATION}, };
How a JWT extractor works in Axum
authentication
jwt
extractors
Intermediate
8 steps
php
<?php namespace App\Http\Middleware;
Enforcing a JSON Accept header in Laravel
middleware
content-negotiation
http-headers
Beginner
5 steps
typescript
import { Injectable, NestInterceptor, ExecutionContext,
How a NestJS logging interceptor works
interceptors
rxjs
logging
Intermediate
5 steps
go
package middleware import ( "net/http"
Building a bearer-token auth middleware in Gin
middleware
authentication
closures
Intermediate
5 steps