rest

java
@RestController
@RequestMapping("/api/transactions")
public class TransactionExportController {

    private final CsvExportService exportService;

Stream a Large CSV Export to the HTTP Response with StreamingResponseBody in Spring Boot

spring-boot streaming csv
by codesnips 3 tabs
python
from datetime import datetime

from pydantic import BaseModel


class UserV1(BaseModel):

Versioning a FastAPI API With APIRouter Mounted Under /v1 and /v2 Prefixes

fastapi api-versioning apirouter
by codesnips 4 tabs
javascript
const express = require('express');
const controller = require('../controllers/userController');

const router = express.Router();

router.use((req, res, next) => {

Versioning an Express API with Router-per-Version Mounts and a Shared Controller Module

express api-versioning rest
by codesnips 4 tabs
python
from rest_framework.throttling import UserRateThrottle


class BurstRateThrottle(UserRateThrottle):
    """Allow short bursts of requests."""
    scope = 'burst'

Django REST Framework throttling for rate limiting

django python rest
by Priya Sharma 3 tabs
typescript
export interface Cursor {
  createdAt: string;
  id: string;
}

export function encodeCursor(c: Cursor): string {

Cursor Pagination for a REST List Endpoint with a Typed Fetch Client

typescript express rest
by codesnips 3 tabs
ruby
Rails.application.routes.draw do
  resources :articles do
    resources :comments, shallow: true, only: %i[index new create show edit update destroy]
  end

  root "articles#index"

Nested Comments on Articles with Shallow Routing and Scoped Lookups in Rails

rails routing controllers
by codesnips 3 tabs
python
from rest_framework import routers
from rest_framework_nested import routers as nested_routers
from . import views

router = routers.DefaultRouter()
router.register(r'posts', views.PostViewSet, basename='post')

Django REST Framework nested routers

django python rest
by Priya Sharma 2 tabs
php
<?php

namespace App\Http\Resources\V1;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;

Versioning a Laravel API with Route Groups and Resource Transformers

laravel api versioning
by codesnips 4 tabs
python
from rest_framework import viewsets, status
from rest_framework.decorators import action
from rest_framework.response import Response
from blog.models import Post
from .serializers import PostSerializer

Django REST Framework viewset actions

django python rest
by Priya Sharma 1 tab
python
from datetime import timedelta

INSTALLED_APPS += ['rest_framework_simplejwt']

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [

Django REST Framework authentication with JWT

django python rest
by Priya Sharma 2 tabs
ruby
module Api
  module V1
    class UsersController < ApplicationController
      before_action :authenticate_user!, except: [:index, :show]
      before_action :set_user, only: [:show, :update, :destroy]

RESTful API design with Rails

ruby rails api
by Sarah Mitchell 4 tabs
go
package validate

import (
	"regexp"
	"unicode/utf8"
)

Per-Field Signup Validation Errors With a Reusable Validator in Go

go validation http
by codesnips 2 tabs