const classafBedSheet::TextResponse

sys::Obj
  afBedSheet::TextResponse

Return from Handler methods to send a text response to the client.

All MimeTypes have a charset of UTF-8 because that is the default encoding of Fantom Strs.

This is purposely a concrete final class so there is no ambiguity as to what it is. For example, if a handler returned an Obj that was both a TextResponse and a "JsonResponse' what is BedSheet supposed to do?

Best practice is to have your Entities implement a toText() or a toJson() method and return the result of that.

Obj myHandler(MyEntity entity) {
  ...
  return entity.toJson
}
fromHtml

Source

static new fromHtml(Str text)

Creates a TextResponse with the MimeType text/html.

fromJson

Source

static new fromJson(Obj jsonObj)

Creates a TextResponse with the MimeType application/json. jsonObj should be serialisable into Json via util::JsonOutStream

fromJsonP

Source

static new fromJsonP(Obj jsonObj, Str callbackFuncName)

Creates a TextResponse with the MimeType application/json. The json is wrapped in the given callback function name. jsonObj should be serialisable into Json via util::JsonOutStream.

fromMimeType

Source

static new fromMimeType(Str text, MimeType mimeType)

Creates a TextResponse with the given MimeType.

fromPlain

Source

static new fromPlain(Str text)

Creates a TextResponse with the MimeType text/plain.

fromXml

Source

static new fromXml(Str text)

Creates a TextResponse with the MimeType text/xml.

mimeType

Source

const MimeType mimeType

text

Source

const Str text