Last active
January 24, 2022 18:48
-
-
Save oharaandrew314/f34c2c06ba350a101490e58f006f4ff0 to your computer and use it in GitHub Desktop.
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
fun main() { | |
val imagesHost = System.getenv("IMAGES_HOST") | |
val imagesApiKey = System.getenv("IMAGES_API_KEY") | |
val dbHost = System.getenv("DB_HOST") | |
val dbUser = System.getenv("DB_USER") | |
val dbPass = System.getenv("DB_PASS") | |
val dbName = System.getenv("DB_NAME") | |
val dataSource = MysqlDataSource().apply { | |
databaseName = dbName | |
serverName = dbHost | |
user = dbUser | |
password = dbPass | |
} | |
val imagesBackend = ClientFilters.SetHostFrom(Uri.of(imagesHost)) | |
.then(ClientFilters.BearerAuth(imagesApiKey)) | |
.then(JavaHttpClient()) | |
val petService = PetService( | |
pets = PetsDao(dataSource), | |
images = ThirdPartyImageClient(imagesBackend) | |
) | |
RestApi(petService) | |
.toHttpHandler() | |
.asServer(SunHttp(port = 8000)) | |
.start() | |
.block() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment