WebRpcProtocol

automorph.protocol.WebRpcProtocol
See theWebRpcProtocol companion object

Web-RPC protocol implementation.

Provides the following Web-RPC functions for service discovery:

  • api.discover - API schema in OpenAPI format

Type parameters

Codec

message codec plugin type

Context

RPC message context type

Node

message node type

Value parameters

decodeRequest

converts a message format node to Web-RPC request

decodeResponse

converts a message format node to Web-RPC response

encodeOpenApi

converts an OpenAPI schema to message format node

encodeRequest

converts a Web-RPC request to message format node

encodeResponse

converts a Web-RPC response to message format node

encodeString

converts a string to message format node

mapError

maps a Web-RPC error to a corresponding exception

mapException

maps an exception to a corresponding Web-RPC error

mapOpenApi

transforms generated OpenAPI schema

messageCodec

message codec plugin

pathPrefix

API path prefix

Attributes

Constructor

Creates a Web-RPC 2.0 protocol implementation.

See also
Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait RpcProtocol[Node, Codec, Context]
class Object
trait Matchable
class Any
Show all

Members list

Type members

Inherited types

type Metadata = Unit

Web-RPC message metadata.

Web-RPC message metadata.

Attributes

Inherited from:
WebRpcCore (hidden)

Value members

Inherited methods

override def apiSchemas: Seq[ApiSchema[Node]]

Attributes

Definition Classes
Inherited from:
WebRpcCore (hidden)

Creates a copy of this protocol with specified message contex type.

Creates a copy of this protocol with specified message contex type.

Type parameters

NewContext

RPC message context type

Attributes

Returns

JSON-RPC protocol

Inherited from:
WebRpcCore (hidden)

Attributes

Definition Classes
[String](MessageType.Call.toString()),ArrowAssoc[String]("Function").->[String](function),ArrowAssoc[String]("Arguments").->[String](arguments.size.toString())) valmessageText:Function0[Some[String]]=(()=>Some.apply[String](WebRpcCore.this.messageCodec.text(WebRpcCore.this.encodeRequest.apply(request)))) Try.apply[Array[Byte]](WebRpcCore.this.messageCodec.serialize(WebRpcCore.this.encodeRequest.apply(request))).recoverWith[Array[Byte]](((x$1:Throwable)=>(x$1:@unchecked)match{ caseerror=> Failure.apply[Nothing](InvalidRequest.apply("Malformedrequest",error)) })).map[Request[Node,Unit,Context]](((messageBody:Array[Byte])=>{ valmessage:Message[Unit]=protocol.Message.apply[Unit]((),messageBody,requestProperties,messageText) valrequestArguments:Seq[Right[Node,Tuple2[String,Node]]]=arguments.map[Right[Node,Tuple2[String,Node]]](((value:Tuple2[String,Node])=>Right.apply[Node,Tuple2[String,Node]](value))).toSeq valrequestPath:String=_root_.scala.StringContext.apply("","/","").s(requestContext.path.getOrElse[String](""),function) valfunctionRequestContext:Context=requestContext.path(requestPath).asInstanceOf[Context] protocol.Request.apply[Node,Unit,Context](message,function,requestArguments,responseRequired,requestId,functionRequestContext) })) }">WebRpcCore
Inherited from:
[String](MessageType.Call.toString()),ArrowAssoc[String]("Function").->[String](function),ArrowAssoc[String]("Arguments").->[String](arguments.size.toString())) valmessageText:Function0[Some[String]]=(()=>Some.apply[String](WebRpcCore.this.messageCodec.text(WebRpcCore.this.encodeRequest.apply(request)))) Try.apply[Array[Byte]](WebRpcCore.this.messageCodec.serialize(WebRpcCore.this.encodeRequest.apply(request))).recoverWith[Array[Byte]](((x$1:Throwable)=>(x$1:@unchecked)match{ caseerror=> Failure.apply[Nothing](InvalidRequest.apply("Malformedrequest",error)) })).map[Request[Node,Unit,Context]](((messageBody:Array[Byte])=>{ valmessage:Message[Unit]=protocol.Message.apply[Unit]((),messageBody,requestProperties,messageText) valrequestArguments:Seq[Right[Node,Tuple2[String,Node]]]=arguments.map[Right[Node,Tuple2[String,Node]]](((value:Tuple2[String,Node])=>Right.apply[Node,Tuple2[String,Node]](value))).toSeq valrequestPath:String=_root_.scala.StringContext.apply("","/","").s(requestContext.path.getOrElse[String](""),function) valfunctionRequestContext:Context=requestContext.path(requestPath).asInstanceOf[Context] protocol.Request.apply[Node,Unit,Context](message,function,requestArguments,responseRequired,requestId,functionRequestContext) })) }">WebRpcCore (hidden)

Attributes

Definition Classes
Inherited from:
Response.apply[Node](Some.apply[Node](resultValue),None).message)) valmessageText:Function0[Some[String]]=(()=>Some.apply[String](WebRpcCore.this.messageCodec.text(WebRpcCore.this.encodeResponse.apply(responseMessage)))) Try.apply[Array[Byte]](WebRpcCore.this.messageCodec.serialize(WebRpcCore.this.encodeResponse.apply(responseMessage))).recoverWith[Array[Byte]](((x$1:Throwable)=>(x$1:@unchecked)match{ caseerror=> Failure.apply[Nothing](InvalidResponse.apply("Malformedresponse",`error₂`)) })).map[Response[Node,Unit]](((messageBody:Array[Byte])=>{ val`message₃`:Message[Unit]=protocol.Message.apply[Unit]((),messageBody,responseMessage.properties,messageText) protocol.Response.apply[Node,Unit](result,`message₃`) })) }">WebRpcCore (hidden)
def mapError(errorToException: (String, Option[Int]) => Throwable): WebRpcProtocol[Node, Codec, Context]

Creates a copy of this protocol with specified Web-RPC error to exception mapping.

Creates a copy of this protocol with specified Web-RPC error to exception mapping.

Value parameters

errorToException

maps a Web-RPC error to a corresponding exception

Attributes

Returns

Web-RPC protocol

Inherited from:
WebRpcCore (hidden)

Creates a copy of this protocol with specified exception to Web-RPC error mapping.

Creates a copy of this protocol with specified exception to Web-RPC error mapping.

Value parameters

exceptionToError

maps an exception classs to a corresponding Web-RPC error type

Attributes

Returns

Web-RPC protocol

Inherited from:
WebRpcCore (hidden)
def mapOpenApi(mapOpenApi: OpenApi => OpenApi): WebRpcProtocol[Node, Codec, Context]

Creates a copy of this protocol with given OpenAPI description transformation.

Creates a copy of this protocol with given OpenAPI description transformation.

Value parameters

mapOpenApi

transforms generated OpenAPI schema

Attributes

Returns

Web-RPC protocol

Inherited from:
WebRpcCore (hidden)

Attributes

Definition Classes
[String](MessageType.Call.toString()),ArrowAssoc[String]("Arguments").->[String](request.size.toString())) requestContext.path.map[Either[ParseError[Unit],Request[Node,Unit,Context]]](((path:String)=>if(path.startsWith(WebRpcCore.this.pathPrefix).&&(path.length().>(WebRpcCore.this.pathPrefix.length()))){ valfunction:String=WebRpcCore.this.functionSeparator.replaceFirstIn(path.substring(WebRpcCore.this.pathPrefix.length(),path.length()),"") valmessage:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties.++[String](Seq.apply[Tuple2[String,String]](ArrowAssoc[String]("Function").->[String](function))),messageText) valrequestArguments:Seq[Right[Node,Tuple2[String,Node]]]=request.map[Right[Node,Tuple2[String,Node]]](((value:Tuple2[String,Node])=>Right.apply[Node,Tuple2[String,Node]](value))).toSeq Right.apply[Nothing,Request[Node,Unit,Context]](protocol.Request.apply[Node,Unit,Context](message,function,requestArguments,responseRequired=true,requestId,requestContext)) }else{ val`message₂`:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties,messageText) Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidRequest.apply(_root_.scala.StringContext.apply("InvalidURLpath:","").s(path),InvalidRequest.$lessinit$greater$default$2),`message₂`)) })).getOrElse[Either[ParseError[Unit],Request[Node,Unit,Context]]]({ val`message₃`:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties,messageText) Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidRequest.apply("MissingURLpath",InvalidRequest.$lessinit$greater$default$2),`message₃`)) }) }))">WebRpcCore
Inherited from:
[String](MessageType.Call.toString()),ArrowAssoc[String]("Arguments").->[String](request.size.toString())) requestContext.path.map[Either[ParseError[Unit],Request[Node,Unit,Context]]](((path:String)=>if(path.startsWith(WebRpcCore.this.pathPrefix).&&(path.length().>(WebRpcCore.this.pathPrefix.length()))){ valfunction:String=WebRpcCore.this.functionSeparator.replaceFirstIn(path.substring(WebRpcCore.this.pathPrefix.length(),path.length()),"") valmessage:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties.++[String](Seq.apply[Tuple2[String,String]](ArrowAssoc[String]("Function").->[String](function))),messageText) valrequestArguments:Seq[Right[Node,Tuple2[String,Node]]]=request.map[Right[Node,Tuple2[String,Node]]](((value:Tuple2[String,Node])=>Right.apply[Node,Tuple2[String,Node]](value))).toSeq Right.apply[Nothing,Request[Node,Unit,Context]](protocol.Request.apply[Node,Unit,Context](message,function,requestArguments,responseRequired=true,requestId,requestContext)) }else{ val`message₂`:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties,messageText) Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidRequest.apply(_root_.scala.StringContext.apply("InvalidURLpath:","").s(path),InvalidRequest.$lessinit$greater$default$2),`message₂`)) })).getOrElse[Either[ParseError[Unit],Request[Node,Unit,Context]]]({ val`message₃`:Message[Unit]=protocol.Message.apply[Unit]((),requestBody,requestProperties,messageText) Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidRequest.apply("MissingURLpath",InvalidRequest.$lessinit$greater$default$2),`message₃`)) }) }))">WebRpcCore (hidden)

Attributes

Definition Classes
{ valmessageText:Function0[Some[String]]=(()=>Some.apply[String](WebRpcCore.this.messageCodec.text(WebRpcCore.this.encodeResponse.apply(responseMessage)))) valmessage:Message[Unit]=protocol.Message.apply[Unit]((),responseBody,responseMessage.properties,messageText) Try.apply[Response[Node]](Response.apply[Node](responseMessage)).fold[Either[ParseError[Unit],Response[Node,Unit]]](((`error₂`:Throwable)=>Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidResponse.apply("Malformedresponse",`error₂`),message))),((response:Response[Node])=>response.error.fold[Either[ParseError[Unit],Response[Node,Unit]]](response.resultmatch{ caseNone=> Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidResponse.apply("Invalidresult",None.orNull[Null](refl[Null])),message)) caseSome(result)=> Right.apply[Nothing,Response[Node,Unit]](protocol.Response.apply[Node,Unit](Success.apply[Node](result),message)) })(((`error₃`:ResponseError)=>Right.apply[Nothing,Response[Node,Unit]](protocol.Response.apply[Node,Unit](Failure.apply[Nothing](WebRpcCore.this.mapError.apply(`error₃`.message,`error₃`.code)),message)))))) }))">WebRpcCore
Inherited from:
{ valmessageText:Function0[Some[String]]=(()=>Some.apply[String](WebRpcCore.this.messageCodec.text(WebRpcCore.this.encodeResponse.apply(responseMessage)))) valmessage:Message[Unit]=protocol.Message.apply[Unit]((),responseBody,responseMessage.properties,messageText) Try.apply[Response[Node]](Response.apply[Node](responseMessage)).fold[Either[ParseError[Unit],Response[Node,Unit]]](((`error₂`:Throwable)=>Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidResponse.apply("Malformedresponse",`error₂`),message))),((response:Response[Node])=>response.error.fold[Either[ParseError[Unit],Response[Node,Unit]]](response.resultmatch{ caseNone=> Left.apply[ParseError[Unit],Nothing](ParseError.apply[Unit](InvalidResponse.apply("Invalidresult",None.orNull[Null](refl[Null])),message)) caseSome(result)=> Right.apply[Nothing,Response[Node,Unit]](protocol.Response.apply[Node,Unit](Success.apply[Node](result),message)) })(((`error₃`:ResponseError)=>Right.apply[Nothing,Response[Node,Unit]](protocol.Response.apply[Node,Unit](Failure.apply[Nothing](WebRpcCore.this.mapError.apply(`error₃`.message,`error₃`.code)),message)))))) }))">WebRpcCore (hidden)

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product

Inherited fields

val name: String

Attributes

Inherited from:
WebRpcCore (hidden)