clean code

This commit is contained in:
judy0131 2018-09-03 13:14:33 +08:00
parent 6db6d54e56
commit cf32e770dc
3 changed files with 14 additions and 69 deletions

View File

@ -27,99 +27,48 @@
<version>0.9</version> <version>0.9</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-remote --> <!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-remote -->
<!--<dependency> <dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.11</artifactId> <artifactId>akka-remote_2.11</artifactId>
<version>2.3.12</version> <version>2.3.14</version>
</dependency>--> </dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-remote --> <!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-remote -->
<!--<dependency> <dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.11</artifactId> <artifactId>akka-remote_2.11</artifactId>
<version>2.4.7</version> <version>2.3.14</version>
</dependency>--> </dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor -->
<!--<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>2.3.12</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-actor -->
<dependency> <dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId> <artifactId>akka-actor_2.11</artifactId>
<version>2.5.12</version> <version>2.3.14</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-slf4j -->
<!--<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.11</artifactId>
<version>2.3.12</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-slf4j -->
<dependency> <dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.11</artifactId> <artifactId>akka-slf4j_2.11</artifactId>
<version>2.5.12</version> <version>2.3.14</version>
</dependency> </dependency>
<dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-stream-experimental -->
<!--<dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-stream-experimental_2.11</artifactId> <artifactId>akka-stream-experimental_2.11</artifactId>
<version>2.0.4</version> <version>2.0.4</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-stream -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-stream_2.11</artifactId>
<version>2.5.12</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-core-experimental --> <dependency>
<!--<dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core-experimental_2.11</artifactId> <artifactId>akka-http-core-experimental_2.11</artifactId>
<version>2.0.4</version> <version>2.0.4</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-core -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-core_2.11</artifactId>
<version>10.1.3</version>
</dependency> </dependency>
<dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-experimental -->
<!--<dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-experimental_2.11</artifactId> <artifactId>akka-http-experimental_2.11</artifactId>
<version>2.0.4</version> <version>2.0.4</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http_2.11</artifactId>
<version>10.1.3</version>
</dependency> </dependency>
<dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-spray-json-experimental -->
<!--<dependency>
<groupId>com.typesafe.akka</groupId> <groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-spray-json-experimental_2.11</artifactId> <artifactId>akka-http-spray-json-experimental_2.11</artifactId>
<version>2.0.4</version> <version>2.0.4</version>
</dependency>-->
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-spray-json -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-spray-json_2.11</artifactId>
<version>10.1.3</version>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -19,6 +19,7 @@ object HTTPClient {
val response:CloseableHttpResponse = client.execute(post) val response:CloseableHttpResponse = client.execute(post)
val entity = response.getEntity val entity = response.getEntity
val str = EntityUtils.toString(entity,"UTF-8") val str = EntityUtils.toString(entity,"UTF-8")
println("Code is " + str)
} }
} }

View File

@ -3,18 +3,14 @@ package cn.piflow.api
import java.io.File import java.io.File
import java.util.concurrent.CompletionStage import java.util.concurrent.CompletionStage
import akka.NotUsed
import akka.actor.ActorSystem import akka.actor.ActorSystem
import akka.http.scaladsl.Http import akka.http.scaladsl.Http
import akka.http.scaladsl.common.{EntityStreamingSupport, JsonEntityStreamingSupport}
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.model._ import akka.http.scaladsl.model._
import akka.http.scaladsl.model.HttpMethods._ import akka.http.scaladsl.model.HttpMethods._
import akka.http.scaladsl.server.Directives import akka.http.scaladsl.server.Directives
import akka.http.impl.util.StreamUtils
import akka.stream.ActorMaterializer import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{FileIO, Framing, Sink, Source}
import akka.util.ByteString
import cn.piflow.api.util.PropertyUtil import cn.piflow.api.util.PropertyUtil
import com.typesafe.config.ConfigFactory import com.typesafe.config.ConfigFactory
@ -28,7 +24,6 @@ object HTTPService extends DefaultJsonProtocol with Directives with SprayJsonSup
implicit val system = ActorSystem("HTTPService", ConfigFactory.load()) implicit val system = ActorSystem("HTTPService", ConfigFactory.load())
implicit val materializer = ActorMaterializer() implicit val materializer = ActorMaterializer()
implicit val executionContext = system.dispatcher implicit val executionContext = system.dispatcher
implicit val jsonStreamingSupport : JsonEntityStreamingSupport = EntityStreamingSupport.json
var processMap = Map[String, Process]() var processMap = Map[String, Process]()
def toJson(entity: RequestEntity): Map[String, Any] = { def toJson(entity: RequestEntity): Map[String, Any] = {