GETTING STARTED

MAIN CONCEPTS

API

Context

The context is an object that gets passed as the first and only argument to any response handlers you define. In the below example it has been defined simply as t.

const response = (t) => {
  if (t.request.method === 'GET') {
    return { text: 'GET request received' }
  }

  else {
    return { text: 'Expected a GET request' }
  }
}

Contained within are methods and properties related to the current HTTP transaction. For more information, see the API section on TuftContext.