vapor-docs/build/3.0/concepts/http/index.html

1338 lines
34 KiB
HTML

<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="lang:clipboard.copy" content="Copy to clipboard">
<meta name="lang:clipboard.copied" content="Copied to clipboard">
<meta name="lang:search.language" content="en">
<meta name="lang:search.result.none" content="No matching documents">
<meta name="lang:search.result.one" content="1 matching document">
<meta name="lang:search.result.other" content="# matching documents">
<meta name="lang:search.tokenizer" content="[\s\-]+">
<link rel="shortcut icon" href="../../assets/images/favicon.png">
<meta name="generator" content="mkdocs-0.17.2, mkdocs-material-2.0.4">
<title>HTTP - Vapor Docs</title>
<link rel="stylesheet" href="../../assets/stylesheets/application-709eec9410.css">
<link rel="stylesheet" href="../../assets/stylesheets/application-23f75ab9c7.palette.css">
<script src="../../assets/javascripts/modernizr-e826f8942a.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700|Roboto+Mono">
<style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body data-md-color-primary="blue" data-md-color-accent="purple">
<svg class="md-svg">
<defs>
<svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg>
</defs>
</svg>
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="drawer">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="search">
<label class="md-overlay" data-md-component="overlay" for="drawer"></label>
<header class="md-header" data-md-component="header">
<nav class="md-header-nav md-grid">
<div class="md-flex">
<div class="md-flex__cell md-flex__cell--shrink">
<a href="../.." title="Vapor Docs" class="md-header-nav__button md-logo">
<img src="../../images/droplet-white.svg" width="24" height="24">
</a>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--menu md-header-nav__button" for="drawer"></label>
</div>
<div class="md-flex__cell md-flex__cell--stretch">
<span class="md-flex__ellipsis md-header-nav__title">
<span class="md-header-nav__parent">
Concepts
</span>
HTTP
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<label class="md-icon md-icon--search md-header-nav__button" for="search"></label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="search"></label>
<div class="md-search__inner">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" required placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query">
<label class="md-icon md-search__icon" for="search"></label>
<button type="reset" class="md-icon md-search__icon" data-md-component="reset">&#xE5CD;</button>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" data-md-scrollfix>
<div class="md-search-result" data-md-component="result">
<div class="md-search-result__meta">
Type to start searching
</div>
<ol class="md-search-result__list"></ol>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<div class="md-header-nav__source">
<a href="http://github.com/vapor/vapor/" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container">
<main class="md-main">
<div class="md-main__inner md-grid" data-md-component="container">
<div class="md-sidebar md-sidebar--primary" data-md-component="navigation">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" data-md-level="0">
<label class="md-nav__title md-nav__title--site" for="drawer">
<span class="md-nav__button md-logo">
<img src="../../images/droplet-white.svg" width="24" height="24">
</span>
Vapor Docs
</label>
<div class="md-nav__source">
<a href="http://github.com/vapor/vapor/" title="Go to repository" class="md-source" data-md-source="github">
<div class="md-source__icon">
<svg viewBox="0 0 24 24" width="24" height="24">
<use xlink:href="#github" width="24" height="24"></use>
</svg>
</div>
<div class="md-source__repository">
GitHub
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." title="Overview" class="md-nav__link">
Overview
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-2" type="checkbox" id="nav-2">
<label class="md-nav__link" for="nav-2">
Install
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-2">
Install
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../install/macos/" title="macOS" class="md-nav__link">
macOS
</a>
</li>
<li class="md-nav__item">
<a href="../../install/ubuntu/" title="Ubuntu" class="md-nav__link">
Ubuntu
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3">
<label class="md-nav__link" for="nav-3">
Getting started
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-3">
Getting started
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../getting-started/hello-world/" title="Hello, world" class="md-nav__link">
Hello, world
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/toolbox/" title="Toolbox" class="md-nav__link">
Toolbox
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/spm/" title="SPM" class="md-nav__link">
SPM
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/xcode/" title="Xcode" class="md-nav__link">
Xcode
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/structure/" title="Folder Structure" class="md-nav__link">
Folder Structure
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/application/" title="Application" class="md-nav__link">
Application
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/controllers/" title="Controllers" class="md-nav__link">
Controllers
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/routing/" title="Routing" class="md-nav__link">
Routing
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/content/" title="Content" class="md-nav__link">
Content
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/futures/" title="Futures" class="md-nav__link">
Futures
</a>
</li>
<li class="md-nav__item">
<a href="../../getting-started/cloud/" title="Deployment" class="md-nav__link">
Deployment
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4" checked>
<label class="md-nav__link" for="nav-4">
Concepts
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-4">
Concepts
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../vapor/" title="Vapor" class="md-nav__link">
Vapor
</a>
</li>
<li class="md-nav__item">
<a href="../content/" title="Content" class="md-nav__link">
Content
</a>
</li>
<li class="md-nav__item">
<a href="../services/" title="Services" class="md-nav__link">
Services
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="toc">
<label class="md-nav__link md-nav__link--active" for="toc">
HTTP
</label>
<a href="./" title="HTTP" class="md-nav__link md-nav__link--active">
HTTP
</a>
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#what-is-the-difference" title="What is the difference?" class="md-nav__link">
What is the difference?
</a>
</li>
<li class="md-nav__item">
<a href="#how-it-works" title="How it works" class="md-nav__link">
How it works
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#request" title="Request" class="md-nav__link">
Request
</a>
</li>
<li class="md-nav__item">
<a href="#response" title="Response" class="md-nav__link">
Response
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#handling-requests" title="Handling requests" class="md-nav__link">
Handling requests
</a>
</li>
<li class="md-nav__item">
<a href="#types-of-endpoints" title="Types of endpoints" class="md-nav__link">
Types of endpoints
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#websites" title="Websites" class="md-nav__link">
Websites
</a>
</li>
<li class="md-nav__item">
<a href="#api" title="API" class="md-nav__link">
API
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../code-contributions/" title="Code Contributions" class="md-nav__link">
Code Contributions
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-5" type="checkbox" id="nav-5">
<label class="md-nav__link" for="nav-5">
Async
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-5">
Async
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../async/getting-started/" title="Package" class="md-nav__link">
Package
</a>
</li>
<li class="md-nav__item">
<a href="../../async/futures/" title="Futures" class="md-nav__link">
Futures
</a>
</li>
<li class="md-nav__item">
<a href="../../async/streams/" title="Streams" class="md-nav__link">
Streams
</a>
</li>
<li class="md-nav__item">
<a href="../../async/eventloop/" title="EventLoop" class="md-nav__link">
EventLoop
</a>
</li>
<li class="md-nav__item">
<a href="../../async/reactive/" title="Reactive Programming" class="md-nav__link">
Reactive Programming
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-6" type="checkbox" id="nav-6">
<label class="md-nav__link" for="nav-6">
HTTP
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-6">
HTTP
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../http/getting-started/" title="Package" class="md-nav__link">
Package
</a>
</li>
<li class="md-nav__item">
<a href="../../http/body/" title="Body" class="md-nav__link">
Body
</a>
</li>
<li class="md-nav__item">
<a href="../../http/client/" title="Client" class="md-nav__link">
Client
</a>
</li>
<li class="md-nav__item">
<a href="../../http/cookies/" title="Cookies" class="md-nav__link">
Cookies
</a>
</li>
<li class="md-nav__item">
<a href="../../http/headers/" title="Headers" class="md-nav__link">
Headers
</a>
</li>
<li class="md-nav__item">
<a href="../../http/method/" title="Methods" class="md-nav__link">
Methods
</a>
</li>
<li class="md-nav__item">
<a href="../../http/middleware/" title="Middleware" class="md-nav__link">
Middleware
</a>
</li>
<li class="md-nav__item">
<a href="../../http/multipart/" title="Multipart" class="md-nav__link">
Multipart
</a>
</li>
<li class="md-nav__item">
<a href="../../http/status/" title="Status codes" class="md-nav__link">
Status codes
</a>
</li>
<li class="md-nav__item">
<a href="../../http/uri/" title="URI" class="md-nav__link">
URI
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-7" type="checkbox" id="nav-7">
<label class="md-nav__link" for="nav-7">
Redis
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-7">
Redis
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../redis/getting-started/" title="Package" class="md-nav__link">
Package
</a>
</li>
<li class="md-nav__item">
<a href="../../redis/basics/" title="Basics" class="md-nav__link">
Basics
</a>
</li>
<li class="md-nav__item">
<a href="../../redis/custom-commands/" title="Custom commands" class="md-nav__link">
Custom commands
</a>
</li>
<li class="md-nav__item">
<a href="../../redis/pub-sub/" title="Publish and Subscribe" class="md-nav__link">
Publish and Subscribe
</a>
</li>
<li class="md-nav__item">
<a href="../../redis/pipeline/" title="Pipeline" class="md-nav__link">
Pipeline
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../../websocket/websocket/" title="WebSocket" class="md-nav__link">
WebSocket
</a>
</li>
<li class="md-nav__item">
<a href="../../services/getting-started/" title="Services" class="md-nav__link">
Services
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-10" type="checkbox" id="nav-10">
<label class="md-nav__link" for="nav-10">
Crypto
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-10">
Crypto
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../crypto/getting-started/" title="Package" class="md-nav__link">
Package
</a>
</li>
<li class="md-nav__item">
<a href="../../crypto/base64/" title="Base64" class="md-nav__link">
Base64
</a>
</li>
<li class="md-nav__item">
<a href="../../crypto/hash/" title="Hashes" class="md-nav__link">
Hashes
</a>
</li>
<li class="md-nav__item">
<a href="../../crypto/mac/" title="Message authentication" class="md-nav__link">
Message authentication
</a>
</li>
<li class="md-nav__item">
<a href="../../crypto/passwords/" title="Password hashing" class="md-nav__link">
Password hashing
</a>
</li>
<li class="md-nav__item">
<a href="../../crypto/random/" title="Random" class="md-nav__link">
Random
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-toggle md-nav__toggle" data-md-toggle="nav-11" type="checkbox" id="nav-11">
<label class="md-nav__link" for="nav-11">
Version (3.0-alpha)
</label>
<nav class="md-nav" data-md-component="collapsible" data-md-level="1">
<label class="md-nav__title" for="nav-11">
Version (3.0-alpha)
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../version/1_5/" title="1.5" class="md-nav__link">
1.5
</a>
</li>
<li class="md-nav__item">
<a href="../../version/2_0/" title="2.0" class="md-nav__link">
2.0
</a>
</li>
<li class="md-nav__item">
<a href="../../version/3_0/" title="3.0-alpha" class="md-nav__link">
3.0-alpha
</a>
</li>
<li class="md-nav__item">
<a href="../../version/support/" title="Support" class="md-nav__link">
Support
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="toc">
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary">
<label class="md-nav__title" for="toc">Table of contents</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="#what-is-the-difference" title="What is the difference?" class="md-nav__link">
What is the difference?
</a>
</li>
<li class="md-nav__item">
<a href="#how-it-works" title="How it works" class="md-nav__link">
How it works
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#request" title="Request" class="md-nav__link">
Request
</a>
</li>
<li class="md-nav__item">
<a href="#response" title="Response" class="md-nav__link">
Response
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#handling-requests" title="Handling requests" class="md-nav__link">
Handling requests
</a>
</li>
<li class="md-nav__item">
<a href="#types-of-endpoints" title="Types of endpoints" class="md-nav__link">
Types of endpoints
</a>
<nav class="md-nav">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#websites" title="Websites" class="md-nav__link">
Websites
</a>
</li>
<li class="md-nav__item">
<a href="#api" title="API" class="md-nav__link">
API
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content">
<article class="md-content__inner md-typeset">
<a href="https://github.com/vapor/documentation/edit/beta/3.0/docs/concepts/http.md" title="Edit this page" class="md-icon md-content__icon">&#xE3C9;</a>
<h1 id="http">HTTP<a class="headerlink" href="#http" title="Permanent link">&para;</a></h1>
<p>At the heart of the web lies HTTP. HTTP (or HyperText Transfer Protocol) is used for communicating multiple types of media between a client and a server.</p>
<p>HTTP comes in two major versions. <code>HTTP/1</code> and <code>HTTP/2</code>. Vapor comes with HTTP/1 support by default but has an official package for HTTP/2, too.</p>
<h3 id="what-is-the-difference">What is the difference?<a class="headerlink" href="#what-is-the-difference" title="Permanent link">&para;</a></h3>
<p>HTTP/1 is a protocol designed in the '90s for the then new and rapidly evolving internet. The protocol is designed around simplicity above security and functionality.</p>
<p>HTTP/2 is a protocol with security and performance in mind. Designed with experience of the past 20 years of internet in addition to modern standards such as a high bandwidth and many resources per page.</p>
<h2 id="how-it-works">How it works<a class="headerlink" href="#how-it-works" title="Permanent link">&para;</a></h2>
<p>At the heart of HTTP lie the <a href="../http/request.md">Request</a> and <a href="../http/response.md">Response</a> types. Both of them are "HTTP Messages". Both HTTP messages consists of <a href="../../http/headers/">Headers</a> and a <a href="../../http/body/">body</a>.</p>
<p>HTTP clients connect to an HTTP server. The clients can send a request to which the server will send a response.</p>
<p>Bodies contain the concrete information being transferred. Think of the web-page, images, videos, JSON and <a href="../../http/multipart/">forms</a>.</p>
<p>Headers contain metadata, meaning they carry information describing the HTTP message, it's context and it's content.</p>
<p><a href="../../http/cookies/">Cookies</a> are context metadata about the client that, for example, can be used for identifying users after they've (successfully) logged in. One of these methods are <a href="../jwt/getting-started.md">session tokens</a>.</p>
<p>Another type of metadata that is often used to define the type of content transferred in the body is the <code>Content-Type</code> header</p>
<h3 id="request">Request<a class="headerlink" href="#request" title="Permanent link">&para;</a></h3>
<p>Requests have two additional properties in addition to all properties of a Message. The <a href="../../http/method/">Method</a> and <a href="../../http/uri/">path</a>.</p>
<p>The path is used to specify the resource being accessed. Although there are conventions, there are no rules/limitations to how you structure your paths except their format. Paths consist of <a href="../routing/parameters.md">components</a>. The components are separated by a forward slash (<code>/</code>). All components must be encoded with percent encoding, affecting special characters only.</p>
<p>The <a href="../../http/method/">method</a> indicated the operation to this resource. <code>GET</code> is used for reading a resource where <code>DELETE</code> will (attempt to) remove the resource. This does not mean you need to blindly comply. If a user doesn't have the permissions for said operation, you can emit a response indicating this.</p>
<h3 id="response">Response<a class="headerlink" href="#response" title="Permanent link">&para;</a></h3>
<p>Responses have one additional property in addition to the message's properties. This is <a href="../../http/status/">the status code</a>. The status code is used to indicate to the client what the status/result is of a Request. If a client was not authenticated, for example, you would return a status 401 or 403 for "Unauthorized" or "Forbidden" respectively. <a href="../../http/status/">More about status codes here.</a></p>
<h2 id="handling-requests">Handling requests<a class="headerlink" href="#handling-requests" title="Permanent link">&para;</a></h2>
<p>Requests in Vapor will be handled by a <a href="../../getting-started/routing/">router</a>. This allows registering a path to a method. For example, registering <code>.get("users")</code> will register the path <code>/users/</code> to the method <code>GET</code>. The responder/closure associated with this route can then handle requests sent to <code>/users/</code> with the <code>GET</code> method.</p>
<h2 id="types-of-endpoints">Types of endpoints<a class="headerlink" href="#types-of-endpoints" title="Permanent link">&para;</a></h2>
<p>In the web we usually define two types of endpoints. Either a website or an API. Websites are HTML pages, usually with associated styling, code and images. APIs are endpoints that communicate with raw information rather than types and user friendly information. APIs are aimed to developers and their applications.</p>
<p>iOS and Android apps usually communicate with an API, where a web browser such as Safari, Firefox, Chrome or Edge will usually communicate with a website.</p>
<h3 id="websites">Websites<a class="headerlink" href="#websites" title="Permanent link">&para;</a></h3>
<p>Websites come in two major flavours. Server and client rendered pages. "Rendering" in this context doesn't mean the graphical rendering on your monitor, but instead the way information is injected into the HTML DOM to display the information to the users.</p>
<p>Server rendered pages make use of a templating system such as <a href="../leaf/getting-started.md">leaf</a> whereas client rendered pages communicate with an API.</p>
<h3 id="api">API<a class="headerlink" href="#api" title="Permanent link">&para;</a></h3>
<p>APIs are endpoints that sometimes receive but always reply with raw data. The raw data can be in any format. Most commonly, APIs communicate with <a href="../getting-started/json.md">JSON</a>. Sometimes, they communicate with XML or other data types. Vapor can flexibly switch between supported formats, both by official or by community made libraries.</p>
<p>APIs in Vapor are (almost) always creating using a "MVC" or "Model View Controller" model <a href="../../getting-started/controllers/">which we explain here.</a></p>
<p>Designing an API in Vapor is really simple. <a href="../../getting-started/application/">We dive into this from here.</a></p>
</article>
</div>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-nav">
<nav class="md-footer-nav__inner md-grid">
<a href="../services/" title="Services" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev">
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-back md-footer-nav__button"></i>
</div>
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Previous
</span>
Services
</span>
</div>
</a>
<a href="../code-contributions/" title="Code Contributions" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next">
<div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title">
<span class="md-flex__ellipsis">
<span class="md-footer-nav__direction">
Next
</span>
Code Contributions
</span>
</div>
<div class="md-flex__cell md-flex__cell--shrink">
<i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i>
</div>
</a>
</nav>
</div>
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-footer-copyright">
<div class="md-footer-copyright__highlight">
Copyright &copy; 2017 Qutheory, LLC
</div>
powered by
<a href="http://www.mkdocs.org" title="MkDocs">MkDocs</a>
and
<a href="http://squidfunk.github.io/mkdocs-material/" title="Material for MkDocs">
Material for MkDocs</a>
</div>
<div class="md-footer-social">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<a href="https://twitter.com/@codevapor" class="md-footer-social__link fa fa-twitter"></a>
<a href="http://vapor.team/" class="md-footer-social__link fa fa-slack"></a>
<a href="https://github.com/vapor" class="md-footer-social__link fa fa-github"></a>
</div>
</div>
</div>
</footer>
</div>
<script src="../../assets/javascripts/application-8e4952e681.js"></script>
<script>app.initialize({version:"0.17.2",url:{base:"../.."}})</script>
<script>!function(e,t,a,n,o,c,i){e.GoogleAnalyticsObject=o,e[o]=e[o]||function(){(e[o].q=e[o].q||[]).push(arguments)},e[o].l=1*new Date,c=t.createElement(a),i=t.getElementsByTagName(a)[0],c.async=1,c.src=n,i.parentNode.insertBefore(c,i)}(window,document,"script","https://www.google-analytics.com/analytics.js","ga"),ga("create","UA-76177358-4","auto"),ga("set","anonymizeIp",!0),ga("send","pageview");var links=document.getElementsByTagName("a");Array.prototype.map.call(links,function(e){e.host!=document.location.host&&e.addEventListener("click",function(){var t=e.getAttribute("data-md-action")||"follow";ga("send","event","outbound",t,e.href)})});var query=document.forms.search.query;query.addEventListener("blur",function(){if(this.value){var e=document.location.pathname;ga("send","pageview",e+"?q="+this.value)}})</script>
</body>
</html>