Plug v1.1.3 API Reference

Modules

The plug specification

Adapter interface to the Cowboy webserver

A translator module shared by adapters that ship with Plug

Conveniences for building plugs

Plug to protect from cross-site request forgery

The Plug connection

Specification of the connection adapter API implemented by webservers

Conveniences for encoding and decoding cookies

Conveniences for decoding and encoding url encoded queries

Conveniences for working with status codes

A struct used as default on unfetched fields

Utilities for working with connection data

Namespace and module for crypto functionality

KeyGenerator implements PBKDF2 (Password-Based Key Derivation Function 2), part of PKCS #5 v2.0 (Password-Based Cryptography Specification)

MessageEncryptor is a simple way to encrypt values which get stored somewhere you don’t trust

MessageVerifier makes it easy to generate and verify messages which are signed to prevent tampering

A module (not a plug) for debugging in development

A module to be used in your existing plugs in order to provide error handling

Conveniences for generating HTML

A Plug to convert HEAD requests to GET requests

A plug for logging basic request information in the format

Maps MIME types to file extensions and vice versa

This plug overrides the request’s POST method with the method defined in the _method request parameter

A plug for parsing the request body

Parses JSON request body

Parses multipart request body

Parses urlencoded request body

A plug for generating a unique request id for each request. A generated request id will in the format “uq8hs30oafhj5vve8ji5pmp7mtopc08f”

A DSL to define a routing algorithm that works with Plug

A plug to force SSL connections

A plug to handle session cookies and session stores

Stores the session in a cookie

Stores the session in an in-memory ETS table

Specification for session stores

A plug for serving static assets

Conveniences for testing plugs

A server (a GenServer specifically) that manages uploaded files

Exceptions

Error raised when CSRF token is invalid

Error raised when non-XHR requests are used for Javascript responses

Error raised when trying to modify or send an already sent response

Error raised when the cookie exceeds the maximum size of 4096 bytes

Error raised when trying to send a header that has errors, for example

Raised when the request string is malformed, for example

Error raised when no response is sent in a request

Wraps the connection in an error which is meant to be handled upper in the stack

Raised when the request body contains bad encoding

Error raised when the request body is malformed

Error raised when the request is too large

Error raised when the request body cannot be parsed

Protocols

A protocol that extends exceptions to be status-code aware