Package

com.avsystem.commons

rest

Permalink

package rest

Visibility
  1. Public
  2. All

Type Members

  1. final class Body extends Annotation with BodyTag

    Permalink

    REST methods that can send HTTP body (POST, PATCH, PUT and DELETE) may take a single parameter annotated as Body which will be encoded as HttpBody and sent as the body of HTTP request.

    REST methods that can send HTTP body (POST, PATCH, PUT and DELETE) may take a single parameter annotated as Body which will be encoded as HttpBody and sent as the body of HTTP request. Such a method may not define any other body parameters (although it may take additional Path, Header or Query parameters).

    The single body parameter may have a completely custom encoding to HttpBody which may define its own MIME type and doesn't necessarily have to be JSON.

  2. class BodyField extends rpcName with BodyTag

    Permalink

    REST method parameters annotated as BodyField will be encoded as either JsonValue and combined into a JSON object that will be sent as HTTP body.

    REST method parameters annotated as BodyField will be encoded as either JsonValue and combined into a JSON object that will be sent as HTTP body. Body parameters are allowed only in REST methods annotated as POST, PATCH, PUT or DELETE. Actually, parameters of these methods are interpreted as BodyField by default which means that this annotation rarely needs to be applied explicitly.

  3. sealed abstract class BodyMethodTag extends HttpMethodTag

    Permalink

    Base trait for annotations representing HTTP methods which may define a HTTP body.

    Base trait for annotations representing HTTP methods which may define a HTTP body. This includes PUT, POST, PATCH and DELETE. Parameters of REST methods annotated with one of these tags are by default serialized into JSON (through encoding to JsonValue) and combined into JSON object that is sent as HTTP body.

    Parameters may also contribute to URL path, HTTP headers and query parameters if annotated as Path, Header or Query.

    REST method may also take a single parameter representing the entire HTTP body. Such parameter must be annotated as Body and must be the only body parameter of that method. Value of this parameter will be encoded as HttpBody which doesn't necessarily have to be JSON (it may define its own MIME type).

    Example:
    1. trait SomeRestApi {
        @POST("users/create") def createUser(@Body user: User): Future[Unit]
        @PATCH("users/update") def updateUser(id: String, name: String): Future[User]
      }
      object SomeRestApi extends RestApiCompanion[SomeRestApi]
  4. sealed trait BodyTag extends Annotation with RestParamTag

    Permalink
  5. trait ClientInstances[Real] extends AnyRef

    Permalink
  6. trait CodecWithStructure[T] extends AnyRef

    Permalink
  7. class DELETE extends BodyMethodTag

    Permalink

    See BodyMethodTag

  8. abstract class DefaultRestApiCompanion[Real] extends RestOpenApiCompanion[DefaultRestImplicits, Real]

    Permalink

    Base class for companions of REST API traits used for both REST clients and servers.

    Base class for companions of REST API traits used for both REST clients and servers. Injects GenCodec and GenKeyCodec based serialization and forces derivation of OpenApiMetadata.

  9. abstract class DefaultRestClientApiCompanion[Real] extends RestClientApiCompanion[DefaultRestImplicits, Real]

    Permalink

    Base class for companions of REST API traits used only for REST clients to external services.

    Base class for companions of REST API traits used only for REST clients to external services. Injects GenCodec and GenKeyCodec based serialization.

  10. trait DefaultRestImplicits extends FutureRestImplicits with GenCodecRestImplicits

    Permalink
  11. abstract class DefaultRestServerApiCompanion[Real] extends RestServerOpenApiCompanion[DefaultRestImplicits, Real]

    Permalink

    Base class for companions of REST API traits used only for REST servers exposed to external world.

    Base class for companions of REST API traits used only for REST servers exposed to external world. Injects GenCodec and GenKeyCodec based serialization and forces derivation of OpenApiMetadata.

  12. trait FloatingPointRestImplicits extends AnyRef

    Permalink
  13. class FormBody extends Annotation with StaticAnnotation

    Permalink

    Causes the body parameters of a HTTP REST method to be encoded as application/x-www-form-urlencoded.

    Causes the body parameters of a HTTP REST method to be encoded as application/x-www-form-urlencoded. Each parameter value itself will be first serialized to QueryValue. This annotation only applies to methods which include HTTP body (i.e. not GET) and it must not be a method with a single body parameter (Body). Methods with single body parameter can send their body as application/x-www-form-urlencoded by defining custom serialization of its parameter into HttpBody.

  14. trait FullInstances[Real] extends ServerInstances[Real] with ClientInstances[Real]

    Permalink
  15. trait FutureRestImplicits extends AnyRef

    Permalink
  16. class GET extends HttpMethodTag

    Permalink

    REST method annotated as @GET will translate to HTTP GET request.

    REST method annotated as @GET will translate to HTTP GET request. By default, parameters of such method are translated into URL query parameters (encoded as QueryValue). Alternatively, each parameter may be annotated as Path or Header which means that it will be translated into HTTP header value

  17. trait GenCodecRestImplicits extends FloatingPointRestImplicits

    Permalink

    Defines GenCodec and GenKeyCodec based serialization for REST API traits.

  18. class Header extends rpcName with NonBodyTag

    Permalink

    REST method parameters annotated as Header will be encoded as HeaderValue and added to HTTP headers.

    REST method parameters annotated as Header will be encoded as HeaderValue and added to HTTP headers. Header name must be explicitly given as argument of this annotation.

  19. final case class HeaderValue(value: String) extends AnyVal with RestValue with Product with Serializable

    Permalink

    Value used as encoding of Header parameters.

  20. sealed trait HttpBody extends AnyRef

    Permalink

    Value used to represent HTTP body.

    Value used to represent HTTP body. Also used as direct encoding of Body parameters. Types that have encoding to JsonValue automatically have encoding to HttpBody which uses application/json MIME type. There is also a specialized encoding provided for Unit which returns empty HTTP body when writing and ignores the body when reading.

  21. case class HttpCall(rpcName: String, pathParams: List[PathValue], metadata: HttpMethodMetadata[_]) extends RestMethodCall with Product with Serializable

    Permalink
  22. case class HttpErrorException(code: Int, payload: commons.OptArg[String] = OptArg.Empty, cause: Throwable = null) extends RuntimeException with NoStackTrace with Product with Serializable

    Permalink
  23. final class HttpMethod extends AbstractValueEnum

    Permalink

    Enum representing HTTP methods.

  24. case class HttpMethodMetadata[T](methodTag: HttpMethodTag, parametersMetadata: RestParametersMetadata, bodyFields: Mapping[ParamMetadata[_]], singleBodyParam: commons.Opt[ParamMetadata[_]], formBody: Boolean, responseType: HttpResponseType[T]) extends RestMethodMetadata[T] with Product with Serializable

    Permalink
  25. sealed abstract class HttpMethodTag extends Annotation with RestMethodTag with AnnotationAggregate

    Permalink
  26. case class HttpResponseType[T]() extends Product with Serializable

    Permalink

    Typeclass used during RestMetadata materialization to determine whether a real method is a valid HTTP method.

    Typeclass used during RestMetadata materialization to determine whether a real method is a valid HTTP method. Usually this means that the result must be a type wrapped into something that captures asynchronous computation, e.g. Future. Because REST framework core tries to be agnostic about this asynchronous wrapper (not everyone likes Futures), there are no default implicits provided for HttpResponseType. They must be provided externally.

    For example, FutureRestImplicits introduces an instance of HttpResponseType for Future[T], for arbitrary type T. For RestMetadata materialization this means that every method which returns a Future is considered a valid HTTP method. FutureRestImplicits is injected into materialization of RestMetadata through one of the base companion classes, e.g. DefaultRestApiCompanion. See MacroInstances for more information on injection of implicits.

    Annotations
    @implicitNotFound( ... )
  27. class InvalidRestApiException extends RestException

    Permalink
  28. final case class JsonValue(value: String) extends AnyVal with RestValue with Product with Serializable

    Permalink

    Value used as encoding of BodyField parameters of non-FormBody methods.

    Value used as encoding of BodyField parameters of non-FormBody methods. Wrapped value MUST be a valid JSON.

  29. sealed trait NonBodyTag extends Annotation with RestParamTag

    Permalink
  30. trait OpenApiFullInstances[Real] extends FullInstances[Real] with OpenApiInstances[Real]

    Permalink
  31. trait OpenApiInstances[Real] extends AnyRef

    Permalink
  32. trait OpenApiServerInstances[Real] extends ServerInstances[Real] with OpenApiInstances[Real]

    Permalink
  33. class PATCH extends BodyMethodTag

    Permalink

    See BodyMethodTag

  34. class POST extends BodyMethodTag

    Permalink

    See BodyMethodTag

  35. class PUT extends BodyMethodTag

    Permalink

    See BodyMethodTag

  36. case class ParamMetadata[T]() extends TypedMetadata[T] with Product with Serializable

    Permalink
  37. class Path extends Annotation with NonBodyTag

    Permalink

    REST method parameters annotated as Path will be encoded as PathValue and appended to URL path, in the declaration order.

    REST method parameters annotated as Path will be encoded as PathValue and appended to URL path, in the declaration order. Parameters of Prefix REST methods are interpreted as Path parameters by default.

  38. case class PathName(value: PathValue) extends PathPatternElement with Product with Serializable

    Permalink
  39. case class PathParam(param: PathParamMetadata[_]) extends PathPatternElement with Product with Serializable

    Permalink
  40. case class PathParamMetadata[T](name: String, pathAnnot: Path) extends TypedMetadata[T] with Product with Serializable

    Permalink
  41. sealed trait PathPatternElement extends AnyRef

    Permalink
  42. final case class PathValue(value: String) extends AnyVal with RestValue with Product with Serializable

    Permalink

    Value used as encoding of Path parameters.

  43. class Prefix extends Annotation with RestMethodTag

    Permalink

    REST methods annotated as Prefix are expected to return another REST API trait as their result.

    REST methods annotated as Prefix are expected to return another REST API trait as their result. They do not yet represent an actual HTTP request but contribute to URL path, HTTP headers and query parameters.

    By default, parameters of a prefix method are interpreted as URL path fragments. Their values are encoded as PathValue and appended to URL path. Alternatively, each parameter may also be explicitly annotated as Header or Query.

    NOTE: REST method is interpreted as prefix method by default which means that there is no need to apply Prefix annotation explicitly unless you want to specify a custom path.

  44. case class PrefixCall(rpcName: String, pathParams: List[PathValue], metadata: PrefixMetadata[_]) extends RestMethodCall with Product with Serializable

    Permalink
  45. case class PrefixMetadata[T](methodTag: Prefix, parametersMetadata: RestParametersMetadata, result: RestMetadata.Lazy[T]) extends RestMethodMetadata[T] with Product with Serializable

    Permalink
  46. class Query extends rpcName with NonBodyTag

    Permalink

    REST method parameters annotated as Query will be encoded as QueryValue and added to URL query parameters.

    REST method parameters annotated as Query will be encoded as QueryValue and added to URL query parameters. Parameters of GET REST methods are interpreted as Query parameters by default.

  47. final case class QueryValue(value: String) extends AnyVal with RestValue with Product with Serializable

    Permalink

    Value used as encoding of Query parameters and BodyField parameters of FormBody methods.

  48. trait RawRest extends AnyRef

    Permalink
    Annotations
    @methodTag( ... )
  49. case class ResolvedCall(root: RestMetadata[_], prefixes: List[PrefixCall], finalCall: HttpCall) extends Product with Serializable

    Permalink
  50. abstract class RestApiCompanion[Implicits, Real] extends AnyRef

    Permalink

    Base class for REST trait companions.

    Base class for REST trait companions. Reduces boilerplate needed in order to define appropriate instances of AsRawReal and RestMetadata for given trait. The Implicits type parameter lets you inject additional implicits into macro materialization of these instances, e.g. DefaultRestImplicits. Usually, for even less boilerplate, this base class is extended by yet another abstract class which fixes the Implicits type, e.g. DefaultRestApiCompanion.

  51. abstract class RestClientApiCompanion[Implicits, Real] extends AnyRef

    Permalink

  52. abstract class RestDataCompanion[T] extends AnyRef

    Permalink

    Base class for companion objects of ADTs (case classes, objects, sealed hierarchies) which are used as parameter or result types in REST API traits.

    Base class for companion objects of ADTs (case classes, objects, sealed hierarchies) which are used as parameter or result types in REST API traits. Automatically provides instances of GenCodec and RestSchema.

    Example:
    1. case class User(id: String, name: String, birthYear: Int)
      object User extends RestDataCompanion[User]
  53. class RestException extends InvalidRpcCall

    Permalink
  54. case class RestMetadata[T](prefixMethods: Mapping[PrefixMetadata[_]], httpGetMethods: Mapping[HttpMethodMetadata[_]], httpBodyMethods: Mapping[HttpMethodMetadata[_]]) extends Product with Serializable

    Permalink
    Annotations
    @implicitNotFound( ... ) @methodTag( ... )
  55. sealed abstract class RestMethodCall extends AnyRef

    Permalink
  56. sealed abstract class RestMethodMetadata[T] extends TypedMetadata[T]

    Permalink
  57. sealed trait RestMethodTag extends Annotation with RpcTag

    Permalink

    Base trait for tag annotations that determine how a REST method is translated into actual HTTP request.

    Base trait for tag annotations that determine how a REST method is translated into actual HTTP request. A REST method may be annotated with one of HTTP method tags (GET, PUT, POST, PATCH, DELETE) which means that this method represents actual HTTP call and is expected to return a Future[Result] where Result is encodable as RestResponse.

    If a REST method is not annotated with any of HTTP method tags, Prefix is assumed by default which means that this method only contributes to URL path, HTTP headers and query parameters but does not yet represent an actual HTTP request. Instead, it is expected to return some other REST API trait.

  58. abstract class RestOpenApiCompanion[Implicits, Real] extends AnyRef

    Permalink

  59. sealed trait RestParamTag extends Annotation with RpcTag

    Permalink
  60. case class RestParameters(path: List[PathValue] = Nil, headers: Mapping[HeaderValue] = Mapping.empty, query: Mapping[QueryValue] = Mapping.empty) extends Product with Serializable

    Permalink
  61. case class RestParametersMetadata(path: List[PathParamMetadata[_]], headers: Mapping[ParamMetadata[_]], query: Mapping[ParamMetadata[_]]) extends Product with Serializable

    Permalink
  62. case class RestRequest(method: HttpMethod, parameters: RestParameters, body: HttpBody) extends Product with Serializable

    Permalink
  63. case class RestResponse(code: Int, headers: Mapping[HeaderValue], body: HttpBody) extends Product with Serializable

    Permalink
  64. abstract class RestServerApiCompanion[Implicits, Real] extends AnyRef

    Permalink

  65. abstract class RestServerOpenApiCompanion[Implicits, Real] extends AnyRef

    Permalink

  66. sealed trait RestValue extends Any

    Permalink
  67. trait ServerInstances[Real] extends AnyRef

    Permalink

Ungrouped