def data()

in app/agent/origin.scala [235:266]


  def data(resource: ResourceType): JsValue = {
    val source: Source = new URI(
      url.replace("%resource%", resource.name)
    ) match {
      case classPathLocation if classPathLocation.getScheme == "classpath" =>
        Source.fromURL(
          new URL(null, classPathLocation.toString, classpathHandler),
          "utf-8"
        )
      case s3Location if s3Location.getScheme == "s3" =>
        val s3Client = S3Client.builder
          .credentialsProvider(credsFromS3Url(s3Location))
          .region(AWS.connectionRegion)
          .build
        val obj = s3Client.getObjectAsBytes(
          GetObjectRequest.builder
            .bucket(s3Location.getHost)
            .key(s3Location.getPath.stripPrefix("/"))
            .build
        )
        Source.fromBytes(obj.asByteArray)
      case otherURL =>
        Source.fromURL(otherURL.toURL, "utf-8")
    }
    val jsonText: String =
      try {
        source.getLines().mkString
      } finally {
        source.close()
      }
    Json.parse(jsonText)
  }