Code Explainers

Code explainers tagged #http

go
package handlers
 
import (
	"net/http"

Content negotiation in Gin handlers

content-negotiation struct-tags rest-api
Intermediate 4 steps
go
package httpx
 
import (
	"net/http"

A retrying HTTP transport in Go

http middleware retry
Intermediate 8 steps
go
package middleware
 
import (
	"crypto/subtle"

Building an API-key middleware in Gin

middleware authentication dependency-injection
Intermediate 5 steps
javascript
const express = require('express');
const compression = require('compression');
const zlib = require('zlib');
 

Tuning Express response compression

compression middleware http
Intermediate 9 steps
php
<?php
 
function uploadDocument(string $endpoint, string $filePath, array $meta): array
{

Uploading a file with cURL in PHP

curl file-upload http
Intermediate 8 steps
go
package middleware
 
import (
	"compress/gzip"

How gzip response compression works in Gin

middleware compression http
Intermediate 8 steps
python
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
from pathlib import Path
 

Parallel file downloads with a thread pool

concurrency thread-pool streaming-io
Intermediate 8 steps
typescript
import {
  ArgumentsHost,
  Catch,
  ExceptionFilter,

A catch-all exception filter in NestJS

error-handling exception-filter http
Intermediate 8 steps
go
package middleware
 
import (
	"time"

Building a request logger middleware in Gin

middleware structured-logging closures
Intermediate 6 steps
go
package fetch
 
import (
	"context"

Concurrent API fetches with errgroup in Go

concurrency goroutines error-handling
Intermediate 8 steps
go
package auth
 
import (
	"net/http"

Building a JWT auth middleware in Gin

middleware jwt authentication
Intermediate 7 steps
typescript
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {
  AsyncValidator,

How an async username validator works in Angular

async-validation reactive-forms rxjs
Intermediate 6 steps
go
package main
 
import (
	"net/http"

How route groups nest in Gin

routing middleware api versioning
Intermediate 6 steps
typescript
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError, timer } from 'rxjs';
import { mergeMap, retryWhen } from 'rxjs/operators';

Exponential backoff retries in Angular

retry exponential-backoff rxjs
Advanced 7 steps
go
package storage
 
import (
	"bufio"

Streaming file downloads safely in Go

http streaming path-traversal
Intermediate 7 steps
java
@WebMvcTest(OrderController.class)
class OrderControllerTest {
 
    @Autowired

Slice testing a controller with @WebMvcTest in Spring

testing mocking http
Intermediate 8 steps
go
package middleware
 
import (
	"net/http"

Building a bearer-token auth middleware in Gin

middleware authentication closures
Intermediate 5 steps