const classafBedSheet::TextResponse
sys::Obj afBedSheet::TextResponse
Return from handler methods to send a text response to the client.
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
}
Note: prior to Fantom 1.0.66 the charset will always default to UTF-8 regardless of what is passed into the ctor. See http://fantom.org/sidewalk/topic/2166#c13992.
- fromHtml
static new fromHtml(Str text, Charset charset := Charset.utf8())Creates a
TextResponsewith the MimeTypetext/html.- fromJson
static new fromJson(Obj jsonObj, Charset charset := Charset.utf8())Creates a
TextResponsewith the MimeTypeapplication/json.jsonObjshould be serialisable into Json via util::JsonOutStream- fromJsonP
static new fromJsonP(Obj jsonObj, Str callbackFuncName, Charset charset := Charset.utf8())Creates a
TextResponsewith the MimeTypeapplication/json. The json is wrapped in the given callback function name.jsonObjshould be serialisable into Json via util::JsonOutStream.- fromMimeType
static new fromMimeType(Str text, MimeType mimeType)Creates a
TextResponsewith the given MimeType.- fromPlain
static new fromPlain(Str text, Charset charset := Charset.utf8())Creates a
TextResponsewith the MimeTypetext/plain.- fromXml
static new fromXml(Str text, Charset charset := Charset.utf8())Creates a
TextResponsewith the MimeTypetext/xml.- mimeType
const MimeType mimeType- text
const Str text