|
|
@ -32,10 +32,13 @@ class UserService @Inject() (appDataHandler: AppDataHandler)( |
|
|
|
DefaultFormats ++ JavaTimeSerializers.all |
|
|
|
private val domain = "http://localhost:8080" |
|
|
|
private lazy val baseUrl = uri"$domain/api/chat" |
|
|
|
private lazy val authBasicRequest = (credentials: UserCredentials) => |
|
|
|
basicRequest.auth |
|
|
|
.basic(credentials.username, credentials.password) |
|
|
|
.header("X-AUTH-TOKEN", credentials.token) |
|
|
|
// private lazy val authBasicRequest = (credentials: UserCredentials) => |
|
|
|
// basicRequest.auth |
|
|
|
// .basic(credentials.username, credentials.password) |
|
|
|
// .header("X-AUTH-TOKEN", credentials.token) |
|
|
|
private lazy val tokenBasicRequest = (token: String) => { |
|
|
|
basicRequest.header("X-AUTH-TOKEN", token) |
|
|
|
} |
|
|
|
|
|
|
|
def func1() = async { |
|
|
|
val willBeResponse = func2() |
|
|
@ -59,7 +62,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)( |
|
|
|
// ) |
|
|
|
// ) |
|
|
|
await { |
|
|
|
authBasicRequest(credentials) |
|
|
|
// authBasicRequest(credentials) |
|
|
|
tokenBasicRequest(credentials.token) |
|
|
|
.get(uri"http://localhost:8080/api/chat/get/users") |
|
|
|
.response(asJson[List[String]]) |
|
|
|
.send() |
|
|
@ -69,7 +73,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)( |
|
|
|
def getMessages(credentials: UserCredentials) = async { |
|
|
|
// logger.debug(s"${appDataHandler.appData}") |
|
|
|
await { |
|
|
|
authBasicRequest(credentials) |
|
|
|
// authBasicRequest(credentials) |
|
|
|
tokenBasicRequest(credentials.token) |
|
|
|
.get(uri"http://localhost:8080/api/chat/get/users") |
|
|
|
.response(asJson[List[String]]) |
|
|
|
.send() |
|
|
@ -77,7 +82,8 @@ class UserService @Inject() (appDataHandler: AppDataHandler)( |
|
|
|
} |
|
|
|
|
|
|
|
def getActiveUsers(credentials: UserCredentials) = |
|
|
|
authBasicRequest(credentials) |
|
|
|
// authBasicRequest(credentials) |
|
|
|
tokenBasicRequest(credentials.token) |
|
|
|
.get(uri"http://localhost:8080/api/chat/get/active-users") |
|
|
|
.response(asJson[List[ActiveUser]]) |
|
|
|
.send() |
|
|
|