Skip to content

Instantly share code, notes, and snippets.

package com.lightbend.akka.http.sample
import java.util.UUID
import akka.NotUsed
import akka.actor.{ ActorSystem, Cancellable }
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import scala.collection.mutable
val javaVersion = "1.8"
scalacOptions in ThisBuild ++= Seq( // Copied from https://tpolecat.github.io/2017/04/25/scalac-flags.html
"-target:jvm-" + javaVersion, //
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", "utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
/* "-language:existentials", // Existential types (besides wildcard types) can be written and inferred
A utiliser avec les ressouces "Closable" (fichers, connections bdd etc...)
exemple :
def withFile[A](name: String, encoding: String = "UTF-8")(func: Iterator[String] => A): A = {
val source = Source.fromFile(name, encoding)
val lines = source.getLines()
try {
func(lines)
} finally {
@fmasion
fmasion / gist:7684499
Created November 27, 2013 22:51
Here a way to get around play issue #2015 This will enable you to add a body to WS GET and DELETE methods It uses an Implicit value class to extend WSRequestHolder The only "trick" is to use the same package name to overcome the private[Play] limitation Enjoy
// KEEP CARE TO LET THIS IN THIS PACKAGE
// this enables you to acces and extend private[Play] Objects
package play.api.libs.ws
import scala.concurrent.Future
import java.io.File
import play.api.http.{ Writeable, ContentTypeOf }
import play.api.libs.ws.WS._
import play.api.libs.iteratee.Iteratee