mirror of
https://github.com/corda/corda.git
synced 2024-12-19 04:57:58 +00:00
CordaX500Name JAX-RS parameter converter (#1571)
This commit is contained in:
parent
c93b0284ef
commit
fd9c79659d
@ -0,0 +1,23 @@
|
||||
package net.corda.webserver.converters
|
||||
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import java.lang.reflect.Type
|
||||
import javax.ws.rs.ext.ParamConverter
|
||||
import javax.ws.rs.ext.ParamConverterProvider
|
||||
import javax.ws.rs.ext.Provider
|
||||
|
||||
object CordaX500NameConverter : ParamConverter<CordaX500Name> {
|
||||
override fun toString(value: CordaX500Name) = value.toString()
|
||||
override fun fromString(value: String) = CordaX500Name.parse(value)
|
||||
}
|
||||
|
||||
@Provider
|
||||
object CordaConverterProvider : ParamConverterProvider {
|
||||
override fun <T : Any> getConverter(rawType: Class<T>, genericType: Type?, annotations: Array<out Annotation>?): ParamConverter<T>? {
|
||||
if (rawType == CordaX500Name::class.java) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return CordaX500NameConverter as ParamConverter<T>
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.utilities.loggerFor
|
||||
import net.corda.nodeapi.ArtemisMessagingComponent
|
||||
import net.corda.webserver.WebServerConfig
|
||||
import net.corda.webserver.converters.CordaConverterProvider
|
||||
import net.corda.webserver.services.WebServerPluginRegistry
|
||||
import net.corda.webserver.servlets.*
|
||||
import org.apache.activemq.artemis.api.core.ActiveMQNotConnectedException
|
||||
@ -136,6 +137,7 @@ class NodeWebServer(val config: WebServerConfig) {
|
||||
val resourceConfig = ResourceConfig()
|
||||
.register(ObjectMapperConfig(rpcObjectMapper))
|
||||
.register(ResponseFilter())
|
||||
.register(CordaConverterProvider)
|
||||
.register(APIServerImpl(localRpc))
|
||||
|
||||
val webAPIsOnClasspath = pluginRegistries.flatMap { x -> x.webApis }
|
||||
|
Loading…
Reference in New Issue
Block a user