Skip to content

Request

Elliott Minns edited this page Feb 22, 2016 · 5 revisions

Request

The request object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, the object is always referred to as request (and the HTTP response is response) but its actual name is determined by the parameters to the callback function in which you’re working.

For example:

app.get("/user/:id") { request, response in
    response.send(text: 'user ' + request.data["id"])
}

But you could just as well have:

app.get("/user/:id") { req, res in
    res.send(text: 'user ' + req.data["id"])
}

Properties

let request.method: Method

var parameters: [String: String]

var data: [String: Any]

var cookies: [String: String]

var path: String

var body: Data

var address: String

var files: [String: [MultipartFiles]]

var session: Session

Methods

request.getHeader(String) -> String?

request.setValue(String, forHeader: String)

Roadmap

Guide

Clone this wiki locally