• Add a controller method to handle a HEAD request.

    Returns MethodDecorator

    The new decorator function.

    Example

    // index.ts

    import { Controller, ControllerBase, HEAD, IHttpRequest, IHttpResponse } from '@egomobile/http-server'

    @Controller()
    export default class IndexController extends ControllerBase {
    // can be accessed with a HEAD request
    // by using route /
    @HEAD()
    async index(request: IHttpRequest, response: IHttpResponse) {
    response.writeHead(200, {
    'x-ego-header1': '(root): ' + new Date()
    })
    }

    // can be accessed with a HEAD request
    // by using route /foo
    @HEAD()
    async foo(request: IHttpRequest, response: IHttpResponse) {
    response.writeHead(200, {
    'x-ego-header1': 'foo: ' + new Date()
    })
    }

    // can be accessed with a HEAD request
    // by using route /baz
    @HEAD('/baz')
    async foo(request: IHttpRequest, response: IHttpResponse) {
    response.writeHead(200, {
    'x-ego-header1': 'baz: ' + new Date()
    })
    }
    }
  • Parameters

    Returns MethodDecorator

  • Parameters

    Returns MethodDecorator

  • Parameters

    Returns MethodDecorator

Generated using TypeDoc