Code Explainers
Code explainers tagged #routing
rust
use axum::{ extract::Path, http::StatusCode, routing::{get, post},
Building a REST resource in Axum
rest-api
routing
serialization
Intermediate
9 steps
javascript
import { NavLink, useLocation } from 'react-router-dom'; const NAV_ITEMS = [ { to: '/', label: 'Dashboard', end: true },
Building an accessible Sidebar in React
routing
accessibility
declarative-ui
Intermediate
6 steps
rust
use axum::{ body::Body, http::{header, HeaderValue, StatusCode, Uri}, response::{IntoResponse, Response},
Serving embedded static files in Axum
static-assets
embedding
http-headers
Intermediate
7 steps
typescript
import { Controller, Get, Param, Query, Redirect, NotFoundException } from '@nestjs/common'; import { LinksService } from './links.service'; @Controller('links')
Handling HTTP redirects in NestJS
redirects
routing
decorators
Intermediate
7 steps
php
final class Route { private string $regex; private array $paramNames = [];
Compiling route patterns into regex in PHP
routing
regex
parsing
Intermediate
8 steps
typescript
import { Controller, Get, Param, Post, Body, Version, VERSION_NEUTRAL } from '@nestjs/common'; import { UsersService } from './users.service'; import { CreateUserDto } from './dto/create-user.dto';
How API versioning works in NestJS
api-versioning
routing
dependency-injection
Intermediate
9 steps
python
from fastapi import APIRouter, FastAPI, HTTPException from pydantic import BaseModel
Versioning a FastAPI API with mounted sub-apps
api-versioning
response-models
sub-applications
Intermediate
6 steps
javascript
import { lazy, Suspense } from "react"; import { Routes, Route, NavLink } from "react-router-dom"; import ErrorBoundary from "./components/ErrorBoundary"; import Spinner from "./components/Spinner";
Lazy-loaded routes in React
code-splitting
lazy-loading
routing
Intermediate
6 steps
python
from functools import wraps from flask import Blueprint, session, request, redirect, url_for, flash, render_template from werkzeug.security import check_password_hash
Session-based auth with a Flask Blueprint
authentication
decorators
sessions
Intermediate
9 steps
javascript
const express = require('express'); const router = express.Router(); router.get('/articles/:slug', async (req, res, next) => {
Content negotiation with res.format in Express
content-negotiation
routing
error-handling
Intermediate
9 steps
go
package api func RegisterRoutes(r *gin.Engine, deps *Dependencies) { r.GET("/health", func(c *gin.Context) {
Layering route groups and middleware in Gin
routing
middleware
authentication
Intermediate
8 steps
python
from datetime import datetime from fastapi import APIRouter, Depends, HTTPException, status from pydantic import BaseModel, ConfigDict, EmailStr from sqlalchemy.orm import Session
Building a users router in FastAPI
routing
serialization
dependency-injection
Intermediate
7 steps
typescript
import { Injectable } from '@angular/core'; import { PreloadingStrategy, Route, Routes, RouterModule } from '@angular/router'; import { NgModule } from '@angular/core'; import { Observable, of, timer } from 'rxjs';
A custom preloading strategy in Angular
lazy-loading
preloading
rxjs
Intermediate
7 steps
php
use Illuminate\Support\Facades\Route; use App\Http\Controllers\Admin\DashboardController; use App\Http\Controllers\Admin\UserController; use App\Http\Controllers\Admin\ReportController;
How nested route groups compose in Laravel
routing
middleware
authorization
Intermediate
8 steps
go
package server import ( "net/http"
Serving a single-page app with Gin
static-files
spa
routing
Intermediate
7 steps
rust
use axum::{ http::StatusCode, response::IntoResponse, routing::get,
Serving an SPA and API with Axum
routing
static-files
spa-fallback
Intermediate
7 steps
rust
use axum::{ extract::{Path, State}, http::StatusCode, routing::get,
Building a JSON user API in Axum
routing
shared-state
json-serialization
Intermediate
8 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