/scala-workshop

Primary LanguageScalaApache License 2.0Apache-2.0

Scala Workshop

Setup Environment

Install sdkman

curl -s "https://get.sdkman.io" | bash

Install Java, Scala & SBT

From a new shell, run the following command:

sdk install java 17.0.9-oracle
sdk install scala 2.12.16
sdk install sbt 1.9.8

Setup Wix Environment

  • Install Wix environment as mentioned in here
  • Setup Intellij plugins as mentioned in here

Verify Docker is working

Run the following command:

docker run --rm -p 8080:80 kennethreitz/httpbin

And browse to http://localhost:8080. You should see the home page of HttpBin.

Exercises

Exercise 1

Base64 Decode

  • Send a GET request to http://localhost:8080/base64/{base64_encoded}
  • Example encoded message: dmVsbyBpcyBhd2Vzb21lISEhISEK
  • Print the decoded response
Exercise 2

Redirect

  • Send a GET request to http://localhost:8080/redirect-to?url=http%3A%2F%2Flocalhost%3A8080%2Fuuid&status_code=200
  • Mark the request to not follow redirects (requets.followRedirects(false))
  • Parse the response
  • Send another request according to the value in Location header
Exercise 3

N redirects

  • Send a GET request to "http://localhost:8080/absolute-redirect/{N}"
  • Mark the request to not follow redirects (requets.followRedirects(false))
  • Parse the response
  • Send another request according to the value in Location header
  • Repeat until status code is 200
  • print the result JSON
Exercise 4

Parse JSON

  • Send a GET request to localhost:8080/stream/{N}
  • Parse the received JSON objects to collection of HttpBinPayload

All supported endpoints

http://localhost:8080