Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added initialComponents argument to Bootstrap init
String argumented Bootstrap init will now try to load properties from resources if they are not present in the system, or throw an RuntimeException if they are not present there also. Added HttpHeaderProvider as an possible initialComponent, with default to SettingsHeaderProvider with reads from properties. HttpClient now depends on HttpHeaderProvider to provide it with authorization headers. Removed ProjectSettings, java.util.Properties are now a part of the container. Added simple specification for Bootstrap and HttpHeaderProvider.
- Loading branch information
Showing
14 changed files
with
291 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version := "0.9.0" | ||
version := "0.9.1" | ||
|
||
name := "dsl-client-scala" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
http/src/main/scala/com/dslplatform/api/client/HttpHeaderProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.dslplatform.api.client | ||
|
||
trait HttpHeaderProvider { | ||
def getHeaders: Map[String, String] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 0 additions & 26 deletions
26
http/src/main/scala/com/dslplatform/api/client/ProjectSettings.scala
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
http/src/main/scala/com/dslplatform/api/client/SettingsHeaderProvider.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.dslplatform.api.client | ||
|
||
import java.util.Properties | ||
|
||
import com.ning.http.util.Base64 | ||
|
||
class SettingsHeaderProvider(properties: Properties) extends HttpHeaderProvider { | ||
|
||
private val headers: Map[String, String] = Option(properties.getProperty("auth")).map { | ||
auth => Map("Authorization" -> ("Basic " + auth)) | ||
}.orElse { | ||
Option(properties.getProperty("username")).flatMap { | ||
username => | ||
Option(properties.getProperty("project-id")).map { | ||
projectId => | ||
val token = username + ':' + projectId | ||
val basicAuth = "Basic " + new String(Base64.encode(token.getBytes("UTF-8"))) | ||
Map[String, String]("Authorization" -> basicAuth) | ||
} | ||
} | ||
}.getOrElse(Map.empty[String, String]) | ||
|
||
override def getHeaders: Map[String, String] = headers | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<configuration scan="false" debug="false"> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>[%4p] [%d{HH:mm:ss}]: %m%n</pattern> | ||
</encoder> | ||
</appender> | ||
<root level="Trace"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
username=testUser@dsl-platform.com | ||
project-id=test-password | ||
api-url=https://dsl-platform.com/test | ||
package-name=test.package |
Oops, something went wrong.