Code Explainers
Code explainers tagged #rest
java
public interface GitHubClient { @GetExchange("/users/{username}") GitHubUser getUser(@PathVariable String username);
Declarative HTTP clients in Spring
http-client
declarative-api
proxy
Intermediate
8 steps
ruby
class ProjectsController < ApplicationController before_action :set_project, only: %i[show update destroy] def create
Scoping a Rails API controller to Current.account
multitenancy
strong-parameters
nested-attributes
Intermediate
7 steps
go
package admin import ( "net/http"
Building a protected admin area in Gin
routing
middleware
authentication
Intermediate
6 steps
python
from flask import Blueprint, jsonify, request, abort v1 = Blueprint("users_v1", __name__) v2 = Blueprint("users_v2", __name__)
Versioning a Flask API with Blueprints
api versioning
blueprints
rest
Intermediate
7 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
java
@RestController @RequestMapping("/api/orders") public class OrderController {
Content-negotiated API versioning in Spring
api-versioning
content-negotiation
rest
Intermediate
7 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
ruby
class ArticlesController < ApplicationController before_action :authenticate_user! before_action :set_article, only: %i[show edit update destroy] before_action :authorize_owner!, only: %i[edit update destroy]
How before_action filters guard a Rails controller
filters
authorization
callbacks
Intermediate
9 steps