-
Notifications
You must be signed in to change notification settings - Fork 586
Expand file tree
/
Copy pathRouteDirectives.scala
More file actions
61 lines (52 loc) · 1.45 KB
/
RouteDirectives.scala
File metadata and controls
61 lines (52 loc) · 1.45 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
/*
* Copyright (C) 2009-2018 Lightbend Inc. <https://www.lightbend.com>
*/
package akka.http.scaladsl.server
package directives
import akka.http.scaladsl.marshalling.ToResponseMarshallable
import akka.http.scaladsl.model._
import StatusCodes._
/**
* @groupname route Route directives
* @groupprio route 200
*/
trait RouteDirectives {
/**
* Rejects the request with an empty set of rejections.
*
* @group route
*/
def reject: StandardRoute = RouteDirectives._reject
/**
* Rejects the request with the given rejections.
*
* @group route
*/
def reject(rejections: Rejection*): StandardRoute =
StandardRoute(_.reject(rejections: _*))
/**
* Completes the request with redirection response of the given type to the given URI.
*
* @group route
*/
def redirect(uri: Uri, redirectionType: Redirection): StandardRoute =
StandardRoute(_.redirect(uri, redirectionType))
/**
* Completes the request using the given arguments.
*
* @group route
*/
def complete(m: ⇒ ToResponseMarshallable): StandardRoute =
StandardRoute(_.complete(m))
/**
* Bubbles the given error up the response chain, where it is dealt with by the closest `handleExceptions`
* directive and its ExceptionHandler.
*
* @group route
*/
def failWith(error: Throwable): StandardRoute =
StandardRoute(_.fail(error))
}
object RouteDirectives extends RouteDirectives {
private val _reject = StandardRoute(_.reject())
}