OpineResponse class.

### Hierarchy

- Response

### Implements

- OpineResponse

## Index

### Properties

- #resources
- app
- body
- headers
- locals
- req
- status
- written

### Methods

- addResource
- append
- attachment
- clearCookie
- cookie
- download
- end
- etag
- format
- get
- json
- jsonp
- links
- location
- redirect
- removeHeader
- render
- send
- sendFile
- sendStatus
- set
- setHeader
- setStatus
- type
- unset
- vary

## Properties

### Private #resources

#resources: number[] = []

- Defined in home/runner/work/opine/opine/src/response.ts:49

### app

app: Application

Implementation of OpineResponse.app

- Defined in home/runner/work/opine/opine/src/response.ts:45

### body

body: DenoResponseBody

Implementation of OpineResponse.body

- Defined in home/runner/work/opine/opine/src/response.ts:44

### headers

headers: Headers = new Headers()

Implementation of OpineResponse.headers

- Defined in home/runner/work/opine/opine/src/response.ts:42

### locals

locals: any

Implementation of OpineResponse.locals

- Defined in home/runner/work/opine/opine/src/response.ts:47

### req

req: OpineRequest

Implementation of OpineResponse.req

- Defined in home/runner/work/opine/opine/src/response.ts:46

### status

status: Status = 200

Implementation of OpineResponse.status

- Defined in home/runner/work/opine/opine/src/response.ts:41

### written

written: boolean = false

Implementation of OpineResponse.written

- Defined in home/runner/work/opine/opine/src/response.ts:43

## Methods

### addResource

- addResource(rid: number): void

- Implementation of OpineResponse.addResource

  - Defined in home/runner/work/opine/opine/src/response.ts:58

  Add a resource ID to the list of resources to be closed after the .end() method has been called.

  #### Parameters

  - ##### rid: number

    Resource ID

  #### Returns void

### append

- append(field: string, value: string | string[]): this

- Implementation of OpineResponse.append

  - Defined in home/runner/work/opine/opine/src/response.ts:77

  Append additional header `field` with value `val`. Value can be either a `string` or an array of `string`.

  Example:

  res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); res.append('Warning', '199 Miscellaneous warning'); res.append("cache-control", ["public", "max-age=604800", "immutable"]);

  #### Parameters

  - ##### field: string

  - ##### value: string | string[]

  #### Returns this

  for chaining

### attachment

- attachment(filename: string): this

- Implementation of OpineResponse.attachment

  - Defined in home/runner/work/opine/opine/src/response.ts:96

  Set Content-Disposition header to attachment with optional `filename`.

  #### Parameters

  - ##### filename: string

  #### Returns this

  for chaining

### clearCookie

- clearCookie(cookie: CookieWithOptionalValue): this
- clearCookie(name: string, options?: CookieOptions): this

- Implementation of OpineResponse.clearCookie

  - Defined in home/runner/work/opine/opine/src/response.ts:154

  Clear a cookie.

  #### Parameters

  - ##### cookie: CookieWithOptionalValue

  #### Returns this

  for chaining

- Implementation of OpineResponse.clearCookie

  - Defined in home/runner/work/opine/opine/src/response.ts:155

  #### Parameters

  - ##### name: string

  - ##### Optional options: CookieOptions

  #### Returns this

### cookie

- cookie(name: string, value: string, options: CookieOptions): this
- cookie(cookie: Cookie): this

- Implementation of OpineResponse.cookie

  - Defined in home/runner/work/opine/opine/src/response.ts:118

  Set a cookie. Sets the cookie path to "/" if not defined.

  Examples:

  // "Remember Me" for 15 minutes res.cookie({ name: "rememberme", value: "1", expires: new Date(Date.now() + 900000), httpOnly: true });

  #### Parameters

  - ##### name: string

  - ##### value: string

  - ##### options: CookieOptions

  #### Returns this

  for chaining

- Implementation of OpineResponse.cookie

  - Defined in home/runner/work/opine/opine/src/response.ts:119

  #### Parameters

  - ##### cookie: Cookie

  #### Returns this

### download

- download(path: string, filename?: string, options?: any): Promise<this | void>

- Implementation of OpineResponse.download

  - Defined in home/runner/work/opine/opine/src/response.ts:204

  Transfer the file at the given `path` as an attachment.

  Optionally providing an alternate attachment `filename`.

  Optionally providing an `options` object to use with `res.sendFile()`.

  This function will set the `Content-Disposition` header, overriding any existing `Content-Disposition` header in order to set the attachment and filename.

  This method uses `res.sendFile()`.

  #### Parameters

  - ##### path: string

  - ##### Optional filename: string

  - ##### Optional options: any

  #### Returns Promise<this | void>

### end

- end(body?: DenoResponseBody): Promise<void>

- Implementation of OpineResponse.end

  - Defined in home/runner/work/opine/opine/src/response.ts:247

  Ends the response process.

  #### Parameters

  - ##### Optional body: DenoResponseBody

  #### Returns Promise<void>

### etag

- etag(chunk: string | Uint8Array | Deno.FileInfo): this

- Implementation of OpineResponse.etag

  - Defined in home/runner/work/opine/opine/src/response.ts:287

  Sets an ETag header.

  #### Parameters

  - ##### chunk: string | Uint8Array | Deno.FileInfo

  #### Returns this

  for chaining

### format

- format(obj: any): this

- Implementation of OpineResponse.format

  - Defined in home/runner/work/opine/opine/src/response.ts:357

  Respond to the Acceptable formats using an `obj` of mime-type callbacks.

  This method uses `req.accepted`, an array of acceptable types ordered by their quality values. When "Accept" is not present the first callback is invoked, otherwise the first match is used. When no match is performed the server responds with 406 "Not Acceptable".

  Content-Type is set for you, however if you choose you may alter this within the callback using `res.type()` or `res.set('Content-Type', ...)`.

  res.format({ 'text/plain': function(){ res.send('hey'); },

       'text/html': function(){
         res.send('<p>hey</p>');
       },

       'application/json': function(){
         res.send({ message: 'hey' });
       }

  });

  In addition to canonicalized MIME types you may also use extnames mapped to these types:

  res.format({ text: function(){ res.send('hey'); },

       html: function(){
         res.send('<p>hey</p>');
       },

       json: function(){
         res.send({ message: 'hey' });
       }

  });

  By default Express passes an `Error` with a `.status` of 406 to `next(err)` if a match is not made. If you provide a `.default` callback it will be invoked instead.

  #### Parameters

  - ##### obj: any

  #### Returns this

  for chaining

### get

- get(field: string): string

- Implementation of OpineResponse.get

  - Defined in home/runner/work/opine/opine/src/response.ts:393

  Get value for header `field`.

  #### Parameters

  - ##### field: string

  #### Returns string

  the header

### json

- json(body: ResponseBody): this

- - Defined in home/runner/work/opine/opine/src/response.ts:409

  Send JSON response.

  Examples:

      res.json(null);
      res.json({ user: 'deno' });

  #### Parameters

  - ##### body: ResponseBody

  #### Returns this

  for chaining

### jsonp

- jsonp(body: ResponseBody): this

- - Defined in home/runner/work/opine/opine/src/response.ts:435

  Send JSON response with JSONP callback support.

  Examples:

      res.jsonp(null);
      res.jsonp({ user: 'deno' });

  #### Parameters

  - ##### body: ResponseBody

  #### Returns this

  for chaining

### links

- links(links: any): this

- Implementation of OpineResponse.links

  - Defined in home/runner/work/opine/opine/src/response.ts:485

  Set Link header field with the given `links`.

  Examples:

  res.links({ next: 'http://api.example.com/users?page=2', last: 'http://api.example.com/users?page=5' });

  #### Parameters

  - ##### links: any

  #### Returns this

  for chaining

### location

- location(url: string): this

- Implementation of OpineResponse.location

  - Defined in home/runner/work/opine/opine/src/response.ts:515

  Set the location header to `url`.

  The given `url` can also be "back", which redirects to the Referrer or Referer headers or "/".

  Examples:

  res.location('/foo/bar').; res.location('http://example.com'); res.location('../login');

  #### Parameters

  - ##### url: string

  #### Returns this

  for chaining

### redirect

- redirect(url: string): void
- redirect(statusCode: Status, url: string): void

- Implementation of OpineResponse.redirect

  - Defined in home/runner/work/opine/opine/src/response.ts:539

  Redirect to the given `url` with optional response `status` defaulting to `302`.

  The resulting `url` is determined by `res.location()`.

  Examples:

  res.redirect('/foo/bar'); res.redirect('http://example.com'); res.redirect(301, 'http://example.com'); res.redirect('../login'); // /blog/post/1 -> /blog/login

  #### Parameters

  - ##### url: string

  #### Returns void

- Implementation of OpineResponse.redirect

  - Defined in home/runner/work/opine/opine/src/response.ts:540

  #### Parameters

  - ##### statusCode: Status

  - ##### url: string

  #### Returns void

### removeHeader

- removeHeader(field: string): this

- Implementation of OpineResponse.removeHeader

  - Defined in home/runner/work/opine/opine/src/response.ts:603

  Remove a header from the response

  Examples:

      res.removeHeader('Accept');

  #### Parameters

  - ##### field: string

  #### Returns this

  for chaining

### render

- render(view: string, options?: any, callback?: any): void

- - Defined in home/runner/work/opine/opine/src/response.ts:620

  Render `view` with the given `options` and optional callback `fn`. When a callback function is given a response will not be made automatically, otherwise a response of 200 and text/html is given.

  Options:

  - `cache` boolean hinting to the engine it should cache
  - `filename` filename of the view being rendered

  #### Parameters

  - ##### view: string

  - ##### Default value options: any = {}

  - ##### Optional callback: any

  #### Returns void

### send

- send(body: ResponseBody): this

- - Defined in home/runner/work/opine/opine/src/response.ts:660

  Send a response.

  Examples:

      res.send({ some: 'json' });
      res.send('<p>some html</p>');

  #### Parameters

  - ##### body: ResponseBody

  #### Returns this

  for chaining

### sendFile

- sendFile(path: string, options?: any): Promise<this | void>

- Implementation of OpineResponse.sendFile

  - Defined in home/runner/work/opine/opine/src/response.ts:735

  Transfer the file at the given `path`.

  Automatically sets the Content-Type response header field.

  #### Parameters

  - ##### path: string

  - ##### Default value options: any = {}

  #### Returns Promise<this | void>

### sendStatus

- sendStatus(code: Status): this

- Implementation of OpineResponse.sendStatus

  - Defined in home/runner/work/opine/opine/src/response.ts:794

  Send given HTTP status code.

  Sets the response status to `code` and the body of the response to the standard description from deno's http_status.STATUS_TEXT or the code number if no description.

  Examples:

      res.sendStatus(200);

  #### Parameters

  - ##### code: Status

  #### Returns this

  for chaining

### set

- set(field: string, value: string): this
- set(obj: Record<string, string>): this

- Implementation of OpineResponse.set

  - Defined in home/runner/work/opine/opine/src/response.ts:819

  Set header `field` to `value`, or pass an object of header fields.

  Examples:

      res.set('Accept', 'application/json');
      res.set({
        'Accept-Language': 'en-US, en;q=0.5',
        'Accept': 'text/html',
      });

  #### Parameters

  - ##### field: string

  - ##### value: string

  #### Returns this

  for chaining

- Implementation of OpineResponse.set

  - Defined in home/runner/work/opine/opine/src/response.ts:820

  #### Parameters

  - ##### obj: Record<string, string>

  #### Returns this

### setHeader

- setHeader(field: string, value: string): this
- setHeader(obj: Record<string, string>): this

- Implementation of OpineResponse.setHeader

  - Defined in home/runner/work/opine/opine/src/response.ts:860

  Set header `field` to `value`, or pass an object of header fields.

  alias for res.set()

  Examples:

      res.setHeader('Accept', 'application/json');
      res.setHeader({
        'Accept-Language': "en-US, en;q=0.5",
        'Accept': 'text/html',
      });

  #### Parameters

  - ##### field: string

  - ##### value: string

  #### Returns this

  for chaining

- Implementation of OpineResponse.setHeader

  - Defined in home/runner/work/opine/opine/src/response.ts:861

  #### Parameters

  - ##### obj: Record<string, string>

  #### Returns this

### setStatus

- setStatus(code: Status): this

- Implementation of OpineResponse.setStatus

  - Defined in home/runner/work/opine/opine/src/response.ts:876

  Set status `code`.

  This method deviates from Express due to the naming clash with Deno.OpineResponse `status` property.

  #### Parameters

  - ##### code: Status

  #### Returns this

  for chaining

### type

- type(type: string): this

- Implementation of OpineResponse.type

  - Defined in home/runner/work/opine/opine/src/response.ts:897

  Set Content-Type response header with `type`.

  Examples:

      res.type('.html');
      res.type('html');
      res.type('json');
      res.type('application/json');
      res.type('png');

  #### Parameters

  - ##### type: string

  #### Returns this

  for chaining

### unset

- unset(field: string): this

- Implementation of OpineResponse.unset

  - Defined in home/runner/work/opine/opine/src/response.ts:911

  Deletes a header.

  #### Parameters

  - ##### field: string

  #### Returns this

  for chaining

### vary

- vary(field: string | string[]): this

- - Defined in home/runner/work/opine/opine/src/response.ts:925

  Add `field` to Vary. If already present in the Vary set, then this call is simply ignored.

  #### Parameters

  - ##### field: string | string[]

  #### Returns this

  for chaining

Generated using TypeDoc