public class ApplicationResponseFunctionsKt
Modifier and Type | Method and Description |
---|---|
static io.ktor.http.ContentType |
defaultTextContentType(ApplicationCall $receiver,
io.ktor.http.ContentType contentType)
Creates a default ContentType based on the given contentType and current call
|
static java.lang.Object |
respond(ApplicationCall $receiver,
java.lang.Object message,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Sends a message as a response
|
static java.lang.Object |
respond(ApplicationCall $receiver,
io.ktor.http.HttpStatusCode status,
java.lang.Object message,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Sets status and sends a message as a response
|
static java.lang.Object |
respondFile(ApplicationCall $receiver,
java.io.File baseDir,
java.lang.String fileName,
kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a contents of a file with the name fileName in the baseDir folder
|
static java.lang.Object |
respondFile(ApplicationCall $receiver,
java.io.File file,
kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a contents of a file
|
static java.lang.Object |
respondRedirect(ApplicationCall $receiver,
java.lang.String url,
boolean permanent,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a
301 Moved Permanently or 302 Found redirect |
static java.lang.Object |
respondText(ApplicationCall $receiver,
java.lang.String text,
io.ktor.http.ContentType contentType,
io.ktor.http.HttpStatusCode status,
kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a plain text response, using specified text
|
static java.lang.Object |
respondText(ApplicationCall $receiver,
io.ktor.http.ContentType contentType,
io.ktor.http.HttpStatusCode status,
kotlin.jvm.functions.Function1<? super kotlin.coroutines.experimental.Continuation<? super java.lang.String>,? extends java.lang.Object> provider,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a plain text response, using specified provider to build a text
|
static java.lang.Object |
respondWrite(ApplicationCall $receiver,
io.ktor.http.ContentType contentType,
io.ktor.http.HttpStatusCode status,
kotlin.jvm.functions.Function2<? super java.io.Writer,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> writer,
kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Respond with content producer.
|
public static java.lang.Object respond(ApplicationCall $receiver, java.lang.Object message, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Sends a message as a response
public static java.lang.Object respond(ApplicationCall $receiver, io.ktor.http.HttpStatusCode status, java.lang.Object message, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Sets status and sends a message as a response
public static java.lang.Object respondRedirect(ApplicationCall $receiver, java.lang.String url, boolean permanent, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a 301 Moved Permanently
or 302 Found
redirect
public static java.lang.Object respondText(ApplicationCall $receiver, java.lang.String text, io.ktor.http.ContentType contentType, io.ktor.http.HttpStatusCode status, kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a plain text response, using specified text
contentType
- is an optional ContentType, default is ContentType.Text.Plainstatus
- is an optional HttpStatusCode, default is HttpStatusCode.OKpublic static java.lang.Object respondText(ApplicationCall $receiver, io.ktor.http.ContentType contentType, io.ktor.http.HttpStatusCode status, kotlin.jvm.functions.Function1<? super kotlin.coroutines.experimental.Continuation<? super java.lang.String>,? extends java.lang.Object> provider, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a plain text response, using specified provider to build a text
contentType
- is an optional ContentType, default is ContentType.Text.Plainstatus
- is an optional HttpStatusCode, default is HttpStatusCode.OKpublic static java.lang.Object respondFile(ApplicationCall $receiver, java.io.File baseDir, java.lang.String fileName, kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a contents of a file with the name fileName in the baseDir folder
public static java.lang.Object respondFile(ApplicationCall $receiver, java.io.File file, kotlin.jvm.functions.Function1<? super io.ktor.content.OutgoingContent,kotlin.Unit> configure, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Responds to a client with a contents of a file
public static java.lang.Object respondWrite(ApplicationCall $receiver, io.ktor.http.ContentType contentType, io.ktor.http.HttpStatusCode status, kotlin.jvm.functions.Function2<? super java.io.Writer,? super kotlin.coroutines.experimental.Continuation<? super kotlin.Unit>,? extends java.lang.Object> writer, kotlin.coroutines.experimental.Continuation<? super kotlin.Unit> $continuation)
Respond with content producer.
The writer parameter will be called later when engine is ready to produce content. You don't need to close it.
public static io.ktor.http.ContentType defaultTextContentType(ApplicationCall $receiver, io.ktor.http.ContentType contentType)
Creates a default ContentType based on the given contentType and current call
If contentType is null, it tries to fetch already set response header "Content-Type". If the header is not available
text/plain
is used. If contentType is specified, it uses it
Additionally, if charset is not set for either content type, it appends ; charset=UTF-8
to the content type.