Package 

Class JSONKtorFunctionsKt

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final ContentType getApplicationJSON() The application/json content type
      final String getApplicationJSONString() The application/json content type as a string
      final static Unit kjson(Configuration $self, ContentType contentType, Function1<JSONConfig, Unit> block) Register the kjson content converter, configuring the JSONConfig with a lambda.
      final static Unit kjson(Configuration $self, JSONConfig config, ContentType contentType) Register the kjson content converter, supplying a JSONConfig.
      final static Unit kjson(ContentNegotiation.Config $self, ContentType contentType, Function1<JSONConfig, Unit> block) Register the kjson client content converter, configuring the JSONConfig with a lambda.
      final static Unit kjson(ContentNegotiation.Config $self, JSONConfig config, ContentType contentType) Register the kjson client content converter, supplying a JSONConfig.
      final static Headers contentTypeJSON() Get a Headers containing a Content-Type of application/json.
      final static Headers contentTypeJSON(Charset charset) Get a Headers containing a Content-Type of application/json with the specified Charset.
      final static KtorByteChannelOutput channelOutput(ByteWriteChannel channel, Charset charset) Create a KtorByteChannelOutput (convenience function).
      final static OutgoingContent createStreamedJSONContent(Object value, ContentType contentType, Charset charset, JSONConfig config) Create an OutgoingContent to stream JSON output.
      final static Unit respondStream(ApplicationCall $self, ContentType contentType, HttpStatusCode status, Long contentLength, Charset charset, SuspendFunction1<SuspendFunction1<Character, Unit>, Unit> producer) Respond to a call using streamed data.
      final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, String urlString, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer) Make a client call, receiving the response as a stream.
      final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, KType type, String urlString, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer) Make a client call, receiving the response as a stream.
      final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, Url url, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer) Make a client call, receiving the response as a stream.
      final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, KType type, Url url, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer) Make a client call, receiving the response as a stream.
      final static <T extends Any> Unit executeStreamJSON(HttpClient $self, KType type, HttpRequestBuilder requestBuilder, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer) Make a client call with the parameters supplied in a HttpRequestBuilder, receiving the response as a stream.
      final static HeaderValue parsedContentTypeHeader(Headers $self) Get the Content-Type header, parsed into a HeaderValue.
      final static String getParam(HeaderValue $self, String name) Get a named parameter value from a header (e.g.
      final static Unit copyToPipeline(ByteReadChannel $self, IntCoAcceptor<?> acceptor, Integer bufferSize) Copy data from a ByteReadChannel to an IntCoAcceptor.
      final static KType getParamType(TypeInfo $self, Integer index) Get a selected generic class type parameter from a Ktor TypeInfo.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • getApplicationJSON

         final ContentType getApplicationJSON()

        The application/json content type

      • kjson

         final static Unit kjson(Configuration $self, ContentType contentType, Function1<JSONConfig, Unit> block)

        Register the kjson content converter, configuring the JSONConfig with a lambda.

      • kjson

         final static Unit kjson(Configuration $self, JSONConfig config, ContentType contentType)

        Register the kjson content converter, supplying a JSONConfig.

      • kjson

         final static Unit kjson(ContentNegotiation.Config $self, ContentType contentType, Function1<JSONConfig, Unit> block)

        Register the kjson client content converter, configuring the JSONConfig with a lambda.

      • kjson

         final static Unit kjson(ContentNegotiation.Config $self, JSONConfig config, ContentType contentType)

        Register the kjson client content converter, supplying a JSONConfig.

      • contentTypeJSON

         final static Headers contentTypeJSON()

        Get a Headers containing a Content-Type of application/json.

      • contentTypeJSON

         final static Headers contentTypeJSON(Charset charset)

        Get a Headers containing a Content-Type of application/json with the specified Charset.

      • createStreamedJSONContent

         final static OutgoingContent createStreamedJSONContent(Object value, ContentType contentType, Charset charset, JSONConfig config)

        Create an OutgoingContent to stream JSON output.

      • respondStream

         final static Unit respondStream(ApplicationCall $self, ContentType contentType, HttpStatusCode status, Long contentLength, Charset charset, SuspendFunction1<SuspendFunction1<Character, Unit>, Unit> producer)

        Respond to a call using streamed data.

        Parameters:
        contentType - the ContentType
        status - the HttpStatusCode being returned
        contentLength - the content length (if known)
        charset - the Charset
        producer - the producer function which will write the data to a CoOutput (supplied as receiver)
      • receiveStreamJSON

         final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, String urlString, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer)

        Make a client call, receiving the response as a stream. The response must be in the form of a JSON array, and each array item will be deserialized and passed to the consumer function as it is received.

        Parameters:
        urlString - the URL as a String
        method - the HTTP method (default GET)
        body - the request body if required
        expectedStatus - the expected response status (default 200 OK)
        config - the JSONConfig to use when deserializing
        consumer - the consumer function (will be called with each array item)
      • receiveStreamJSON

         final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, KType type, String urlString, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer)

        Make a client call, receiving the response as a stream. The response must be in the form of a JSON array, and each array item will be deserialized and passed to the consumer function as it is received.

        Parameters:
        type - the type of the array item as a KType
        urlString - the URL as a String
        method - the HTTP method (default GET)
        body - the request body if required
        expectedStatus - the expected response status (default 200 OK)
        config - the JSONConfig to use when deserializing
        consumer - the consumer function (will be called with each array item)
      • receiveStreamJSON

         final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, Url url, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer)

        Make a client call, receiving the response as a stream. The response must be in the form of a JSON array, and each array item will be deserialized and passed to the consumer function as it is received.

        Parameters:
        url - the URL as a Url
        method - the HTTP method (default GET)
        body - the request body if required
        expectedStatus - the expected response status (default 200 OK)
        config - the JSONConfig to use when deserializing
        consumer - the consumer function (will be called with each array item)
      • receiveStreamJSON

         final static <T extends Any> Unit receiveStreamJSON(HttpClient $self, KType type, Url url, HttpMethod method, Object body, Headers headers, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer)

        Make a client call, receiving the response as a stream. The response must be in the form of a JSON array, and each array item will be deserialized and passed to the consumer function as it is received.

        Parameters:
        type - the type of the array item as a KType
        url - the URL as a Url
        method - the HTTP method (default GET)
        body - the request body if required
        expectedStatus - the expected response status (default 200 OK)
        config - the JSONConfig to use when deserializing
        consumer - the consumer function (will be called with each array item)
      • executeStreamJSON

         final static <T extends Any> Unit executeStreamJSON(HttpClient $self, KType type, HttpRequestBuilder requestBuilder, HttpStatusCode expectedStatus, JSONConfig config, SuspendFunction1<T, Unit> consumer)

        Make a client call with the parameters supplied in a HttpRequestBuilder, receiving the response as a stream. The response must be in the form of a JSON array, and each array item will be deserialized and passed to the consumer function as it is received.

        Parameters:
        type - the type of the array item as a KType
        expectedStatus - the expected response status (default 200 OK)
        config - the JSONConfig to use when deserializing
        consumer - the consumer function (will be called with each array item)
      • parsedContentTypeHeader

         final static HeaderValue parsedContentTypeHeader(Headers $self)

        Get the Content-Type header, parsed into a HeaderValue.

      • getParam

         final static String getParam(HeaderValue $self, String name)

        Get a named parameter value from a header (e.g. the charset value in application/json;charset=UTF-8).

      • copyToPipeline

         final static Unit copyToPipeline(ByteReadChannel $self, IntCoAcceptor<?> acceptor, Integer bufferSize)

        Copy data from a ByteReadChannel to an IntCoAcceptor.

      • getParamType

         final static KType getParamType(TypeInfo $self, Integer index)

        Get a selected generic class type parameter from a Ktor TypeInfo.