/
annotations.scala
49 lines (43 loc) · 2.54 KB
/
annotations.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package io.udash.legacyrest
import com.avsystem.commons.rpc.MetadataAnnotation
import scala.annotation.StaticAnnotation
/** Marker trait for REST interfaces. */
@deprecated("This annotation is no longer needed", "0.7.0")
class REST extends StaticAnnotation
/** Annotated method name will be skipped in the REST path.
* This annotation cannot be used in interface which you are going to expose.
* It should be used in case of wrapping external API. */
class SkipRESTName extends MetadataAnnotation
/** Forces name of a method used in the interface to REST mapping.
* This annotation has no effect on exposed interface, it should be used in case of wrapping external API.
* If you want to overwrite method name in exposed interface you should use @rpcName annotation. */
class RESTName(val restName: String) extends MetadataAnnotation
/** Forces name of an argument used in the interface to REST mapping. It also affects exposed interfaces. */
class RESTParamName(val restName: String) extends MetadataAnnotation
sealed trait RESTMethod
/** Annotated method will be send using `GET` HTTP method.
* It's a default for requests without body. */
class GET extends MetadataAnnotation with RESTMethod
/** Annotated method will be send using `POST` HTTP method.
* It's a default for requests with body. */
class POST extends MetadataAnnotation with RESTMethod
/** Annotated method will be send using `PATCH` HTTP method. */
class PATCH extends MetadataAnnotation with RESTMethod
/** Annotated method will be send using `PUT` HTTP method. */
class PUT extends MetadataAnnotation with RESTMethod
/** Annotated method will be send using `DELETE` HTTP method. */
class DELETE extends MetadataAnnotation with RESTMethod
sealed trait ArgumentType
/** Annotated argument will be send as an URL part, eg. /method/{value}. */
class URLPart extends MetadataAnnotation with ArgumentType
/** Annotated argument will be send as a query argument, eg. /method/?arg=value.
* It's a default argument type. */
class Query extends MetadataAnnotation with ArgumentType
/** Annotated argument will be send as a body, eg. /method/ JSON(value).
* Only one argument can be annotated. It cannot be mixed with `@BodyValue`. */
class Body extends MetadataAnnotation with ArgumentType
/** Annotated argument will be send as a body part, eg. /method/ JSON(arg -> value).
* It can be used on multiple arguments. It cannot be mixed with `@Body`. */
class BodyValue extends MetadataAnnotation with ArgumentType
/** Annotated argument will be send as a header. */
class Header extends MetadataAnnotation with ArgumentType