com.bybutter.sisyphus.starter.grpc.transcoding.codec.ProtobufDecoder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sisyphus-grpc-transcoding-starter Show documentation
Show all versions of sisyphus-grpc-transcoding-starter Show documentation
Starter for building gRPC server which with HTTP and gRPC Transcoding in Sisyphus Framework
The newest version!
package com.bybutter.sisyphus.starter.grpc.transcoding.codec
import com.bybutter.sisyphus.protobuf.Message
import com.bybutter.sisyphus.protobuf.ProtoTypes
import com.bybutter.sisyphus.protobuf.ProtobufDefinition
import com.bybutter.sisyphus.protobuf.findMessageSupport
import org.springframework.core.ResolvableType
import org.springframework.core.codec.AbstractDataBufferDecoder
import org.springframework.core.io.buffer.DataBuffer
import org.springframework.util.MimeType
class ProtobufDecoder(vararg mimeTypes: MimeType) : AbstractDataBufferDecoder>(*mimeTypes) {
override fun decode(
buffer: DataBuffer,
targetType: ResolvableType,
mimeType: MimeType?,
hints: Map?,
): Message<*, *> {
val fullName = targetType.rawClass.getAnnotation(ProtobufDefinition::class.java).name
return ProtoTypes.findMessageSupport(fullName).parse(buffer.asInputStream(), Int.MAX_VALUE)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy