-
Notifications
You must be signed in to change notification settings - Fork 5
/
example.yaml.scala
76 lines (56 loc) · 2.79 KB
/
example.yaml.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import play.api.mvc.{Action, Controller}
import play.api.data.validation.Constraint
import play.api.inject.{ApplicationLifecycle,ConfigurationProvider}
import de.zalando.play.controllers._
import PlayBodyParsing._
import PlayValidations._
import scala.util._
import javax.inject._
import de.zalando.play.controllers.Base64String
import Base64String._
import scala.math.BigInt
import play.api.mvc.{Action, Controller, Results}
import java.net.URLEncoder
import play.api.http.DefaultWriteables
/**
* This controller is re-generated after each change in the specification.
* Please only place your hand-written code between appropriate comments in the body of the controller.
*/
package example.yaml {
class ExampleYaml @Inject() (lifecycle: ApplicationLifecycle, config: ConfigurationProvider) extends ExampleYamlBase {
// ----- Start of unmanaged code area for constructor ExampleYaml
// ----- End of unmanaged code area for constructor ExampleYaml
val getUserTodos = getUserTodosAction { input: (BigInt, TodosUser_idGetCount) =>
val (user_id, count) = input
// ----- Start of unmanaged code area for action ExampleYaml.getUserTodos
GetUserTodos200(Nil)
// ----- End of unmanaged code area for action ExampleYaml.getUserTodos
}
}
}
package example.yaml {
class TokenService @Inject() (lifecycle: ApplicationLifecycle, config: ConfigurationProvider) extends TokenServiceBase {
// ----- Start of unmanaged code area for constructor TokenService
// ----- End of unmanaged code area for constructor TokenService
val tokenGet = tokenGetAction { input: (String, String, String, TokenGetState) =>
val (redirect_uri, scope, response_type, state) = input
// ----- Start of unmanaged code area for action TokenService.tokenGet
val statePart = state map { s => s"""state=${URLEncoder.encode(s, "UTF-8")}""" } getOrElse ""
val fullUrl = s"$redirect_uri?$statePart&access_token=abracadabra"
val loginSuccessfull = true
if (loginSuccessfull)
TokenGet301(fullUrl)
else
TokenGet401()
// ----- End of unmanaged code area for action TokenService.tokenGet
}
val tokenPost = tokenPostAction { (token: Base64String) =>
// ----- Start of unmanaged code area for action TokenService.tokenPost
// Use implicit conversion to decode the token
val tokenValue: String = token
if ("abracadabra" == tokenValue) TokenPost200(TokenPostResponses200("the name of the user", Seq("admin:org")))
else TokenPost401("Wrong token: " + tokenValue)
// ----- End of unmanaged code area for action TokenService.tokenPost
}
}
}