# ContentType Decorator

Module
import { ContentType } from "@tsed/common"
Source/packages/common/src/mvc/decorators/method/contentType.ts

# Overview

function ContentType(type: string): Function;

# Description

Sets the Content-Type HTTP header to the MIME type as determined by mime.lookup() for the specified type. If type contains the “/” character, then it sets the Content-Type to type.

 @ContentType('.html');              // => 'text/html'
 @ContentType('html');               // => 'text/html'
 @ContentType('json');               // => 'application/json'
 @ContentType('application/json');   // => 'application/json'
 @ContentType('png');                // => image/png
 private myMethod() {}
1
2
3
4
5
6