Code Explainers

Code explainers tagged #http-status

go
type Warning struct {
	Field   string `json:"field"`
	Code    string `json:"code"`
	Message string `json:"message"`

Partial-success responses in Gin

error-handling input-validation http-status
Intermediate 8 steps
php
<?php
 
namespace App\Http\Controllers;
 

Building a health check endpoint in Laravel

health-check invokable-controller error-handling
Intermediate 8 steps
rust
use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
 
use axum::body::Body;

A maintenance-mode gate in Axum

middleware shared-state atomics
Intermediate 7 steps
rust
use axum::{extract::State, http::StatusCode, response::IntoResponse, Json};
use serde::{Deserialize, Serialize};
use std::sync::Arc;
 

Batch inserts with per-item status in Axum

batch-processing error-handling serde
Intermediate 8 steps
ruby
module Rack
  class MaintenanceMode
    RETRY_AFTER = 3600
 

A Rack maintenance-mode middleware in Rails

middleware rack http-status
Intermediate 8 steps
python
from flask import Blueprint, jsonify
from sqlalchemy import text
from sqlalchemy.exc import SQLAlchemyError
 

Building a health check endpoint in Flask

health-check blueprint error-handling
Intermediate 6 steps
typescript
import {
  ArgumentsHost,
  Catch,
  ConflictException,

Turning TypeORM lock errors into 409s in NestJS

exception-handling optimistic-locking http-status
Intermediate 6 steps
go
package middleware
 
import (
	"net/http"

Role-based access control middleware in Gin

middleware authorization closures
Intermediate 7 steps
go
package health
 
import (
	"context"

Building a health check endpoint in Go

health-check context-timeout dependency-probing
Intermediate 8 steps
go
package middleware
 
import (
	"net/http"

A maintenance-mode gate in Gin

middleware atomic-flag concurrency
Intermediate 8 steps
ruby
class HealthController < ApplicationController
  skip_before_action :authenticate_user!, raise: false
  skip_forgery_protection
 

Building a health check endpoint in Rails

health-check monitoring error-handling
Intermediate 7 steps
java
@RestControllerAdvice
public class GlobalExceptionHandler {
 
    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

Centralized error handling in Spring

exception-handling problemdetail rest-api
Intermediate 7 steps
rust
use axum::{
    http::StatusCode,
    response::{IntoResponse, Response},
    Json,

How a custom error type maps to HTTP in Axum

error-handling enums trait-implementation
Intermediate 7 steps
rust
use axum::{extract::Form, http::StatusCode, response::{IntoResponse, Response}, Json};
use serde::Deserialize;
use serde_json::json;
use std::collections::HashMap;

Validating a signup form in Axum

form-validation deserialization error-handling
Intermediate 8 steps