!htc move ServerSettings and ParserSettings up a package to make them accessible both from the java and scala side
This follow the example from akka.stream.
This commit is contained in:
parent
4537fdebf5
commit
d25b3af252
17 changed files with 78 additions and 18 deletions
|
|
@ -2,13 +2,15 @@
|
||||||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http
|
||||||
|
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
import akka.actor.ActorSystem
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
import akka.http.scaladsl.model.{ StatusCode, HttpMethod, Uri }
|
import akka.http.scaladsl.model.{ StatusCode, HttpMethod, Uri }
|
||||||
import akka.http.impl.util._
|
import akka.http.impl.util._
|
||||||
|
import akka.http.impl.engine.parsing.HttpHeaderParser
|
||||||
|
|
||||||
final case class ParserSettings(
|
final case class ParserSettings(
|
||||||
maxUriLength: Int,
|
maxUriLength: Int,
|
||||||
|
|
@ -88,5 +90,29 @@ object ParserSettings extends SettingsCompanion[ParserSettings]("akka.http.parsi
|
||||||
case x ⇒ throw new IllegalArgumentException(s"[$x] is not a legal `error-logging-verbosity` setting")
|
case x ⇒ throw new IllegalArgumentException(s"[$x] is not a legal `error-logging-verbosity` setting")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of ParserSettings using the configuration provided by the given
|
||||||
|
* ActorSystem.
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(system: ActorSystem): ParserSettings = ParserSettings(system)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of ParserSettings using the given Config.
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(config: Config): ParserSettings = ParserSettings(config)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an instance of ParserSettings using the given String of config overrides to override
|
||||||
|
* settings set in the class loader of this class (i.e. by application.conf or reference.conf files in
|
||||||
|
* the class loader of this class).
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(configOverrides: String): ParserSettings = ParserSettings(configOverrides)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2,17 +2,17 @@
|
||||||
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
* Copyright (C) 2009-2014 Typesafe Inc. <http://www.typesafe.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package akka.http.scaladsl
|
package akka.http
|
||||||
|
|
||||||
import com.typesafe.config.Config
|
|
||||||
import scala.language.implicitConversions
|
|
||||||
import scala.concurrent.duration._
|
|
||||||
import akka.ConfigurationException
|
import akka.ConfigurationException
|
||||||
import akka.actor.{ ActorRefFactory, ActorSystem }
|
import akka.actor.{ ActorSystem, ActorRefFactory }
|
||||||
import akka.http.impl.engine.parsing.ParserSettings
|
|
||||||
import akka.http.impl.util._
|
import akka.http.impl.util._
|
||||||
import akka.http.scaladsl.model.HttpHeader
|
import akka.http.scaladsl.model.HttpHeader
|
||||||
import akka.http.scaladsl.model.headers.{ Host, Server }
|
import akka.http.scaladsl.model.headers.{ Host, Server }
|
||||||
|
import com.typesafe.config.Config
|
||||||
|
|
||||||
|
import scala.concurrent.duration._
|
||||||
|
import scala.language.implicitConversions
|
||||||
|
|
||||||
final case class ServerSettings(
|
final case class ServerSettings(
|
||||||
serverHeader: Option[Server],
|
serverHeader: Option[Server],
|
||||||
|
|
@ -57,13 +57,28 @@ object ServerSettings extends SettingsCompanion[ServerSettings]("akka.http.serve
|
||||||
def apply(optionalSettings: Option[ServerSettings])(implicit actorRefFactory: ActorRefFactory): ServerSettings =
|
def apply(optionalSettings: Option[ServerSettings])(implicit actorRefFactory: ActorRefFactory): ServerSettings =
|
||||||
optionalSettings getOrElse apply(actorSystem)
|
optionalSettings getOrElse apply(actorSystem)
|
||||||
|
|
||||||
/** Java API */
|
/**
|
||||||
def create(system: ActorSystem): ServerSettings = apply(system)
|
* Creates an instance of ServerSettings using the configuration provided by the given
|
||||||
|
* ActorSystem.
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(system: ActorSystem): ServerSettings = ServerSettings(system)
|
||||||
|
|
||||||
/** Java API */
|
/**
|
||||||
def create(config: Config): ServerSettings = apply(config)
|
* Creates an instance of ServerSettings using the given Config.
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(config: Config): ServerSettings = ServerSettings(config)
|
||||||
|
|
||||||
/** Java API */
|
/**
|
||||||
def create(configOverrides: String): ServerSettings = apply(configOverrides)
|
* Create an instance of ServerSettings using the given String of config overrides to override
|
||||||
|
* settings set in the class loader of this class (i.e. by application.conf or reference.conf files in
|
||||||
|
* the class loader of this class).
|
||||||
|
*
|
||||||
|
* Java API
|
||||||
|
*/
|
||||||
|
def create(configOverrides: String): ServerSettings = ServerSettings(configOverrides)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.client
|
package akka.http.impl.engine.client
|
||||||
|
|
||||||
|
import akka.http.ParserSettings
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
import scala.concurrent.duration.{ FiniteDuration, Duration }
|
||||||
import akka.http.scaladsl.model.headers.`User-Agent`
|
import akka.http.scaladsl.model.headers.`User-Agent`
|
||||||
import akka.http.impl.engine.parsing.ParserSettings
|
|
||||||
import akka.http.impl.util._
|
import akka.http.impl.util._
|
||||||
|
|
||||||
final case class ClientConnectionSettings(
|
final case class ClientConnectionSettings(
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
|
import akka.http.ParserSettings
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
import akka.parboiled2.CharUtils
|
import akka.parboiled2.CharUtils
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
||||||
|
import akka.http.ParserSettings
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import akka.actor.ActorRef
|
import akka.actor.ActorRef
|
||||||
import akka.stream.stage.{ Context, PushPullStage }
|
import akka.stream.stage.{ Context, PushPullStage }
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
|
import akka.http.ParserSettings
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import akka.http.impl.model.parser.CharacterClasses
|
import akka.http.impl.model.parser.CharacterClasses
|
||||||
import akka.stream.scaladsl.Source
|
import akka.stream.scaladsl.Source
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
package akka.http.impl.engine
|
package akka.http.impl.engine
|
||||||
|
|
||||||
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
||||||
|
import akka.http.ParserSettings
|
||||||
|
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import akka.event.LoggingAdapter
|
import akka.event.LoggingAdapter
|
||||||
import akka.util.ByteString
|
import akka.util.ByteString
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.server
|
package akka.http.impl.engine.server
|
||||||
|
|
||||||
|
import akka.http.ServerSettings
|
||||||
import org.reactivestreams.{ Subscriber, Publisher }
|
import org.reactivestreams.{ Subscriber, Publisher }
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
import akka.util.ByteString
|
import akka.util.ByteString
|
||||||
|
|
@ -18,7 +19,6 @@ import akka.http.impl.engine.parsing._
|
||||||
import akka.http.impl.engine.rendering.{ ResponseRenderingContext, HttpResponseRendererFactory }
|
import akka.http.impl.engine.rendering.{ ResponseRenderingContext, HttpResponseRendererFactory }
|
||||||
import akka.http.impl.engine.TokenSourceActor
|
import akka.http.impl.engine.TokenSourceActor
|
||||||
import akka.http.scaladsl.model._
|
import akka.http.scaladsl.model._
|
||||||
import akka.http.scaladsl.ServerSettings
|
|
||||||
import akka.http.impl.util._
|
import akka.http.impl.util._
|
||||||
import akka.http.impl.engine.ws._
|
import akka.http.impl.engine.ws._
|
||||||
import Websocket.SwitchToWebsocketToken
|
import Websocket.SwitchToWebsocketToken
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
package akka.http.javadsl
|
package akka.http.javadsl
|
||||||
|
|
||||||
import java.lang.{ Iterable ⇒ JIterable }
|
import java.lang.{ Iterable ⇒ JIterable }
|
||||||
|
import akka.http.ServerSettings
|
||||||
|
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
import akka.japi.Util._
|
import akka.japi.Util._
|
||||||
import akka.japi.Function
|
import akka.japi.Function
|
||||||
|
|
@ -13,7 +15,7 @@ import akka.event.LoggingAdapter
|
||||||
import akka.io.Inet
|
import akka.io.Inet
|
||||||
import akka.stream.FlowMaterializer
|
import akka.stream.FlowMaterializer
|
||||||
import akka.stream.javadsl.{ Flow, Source }
|
import akka.stream.javadsl.{ Flow, Source }
|
||||||
import akka.http.scaladsl.{ model ⇒ sm, ServerSettings }
|
import akka.http.scaladsl.{ model ⇒ sm }
|
||||||
import akka.http.javadsl.model._
|
import akka.http.javadsl.model._
|
||||||
|
|
||||||
object Http extends ExtensionId[Http] with ExtensionIdProvider {
|
object Http extends ExtensionId[Http] with ExtensionIdProvider {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package akka.http.scaladsl
|
||||||
|
|
||||||
import java.net.InetSocketAddress
|
import java.net.InetSocketAddress
|
||||||
import java.util.concurrent.ConcurrentHashMap
|
import java.util.concurrent.ConcurrentHashMap
|
||||||
|
import akka.http.ServerSettings
|
||||||
import com.typesafe.config.Config
|
import com.typesafe.config.Config
|
||||||
import scala.util.Try
|
import scala.util.Try
|
||||||
import scala.util.control.NonFatal
|
import scala.util.control.NonFatal
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,12 @@
|
||||||
package akka.http.impl.engine.client
|
package akka.http.impl.engine.client
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
|
import akka.http.ServerSettings
|
||||||
|
|
||||||
import scala.concurrent.Await
|
import scala.concurrent.Await
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
import scala.util.{ Failure, Success, Try }
|
import scala.util.{ Failure, Success, Try }
|
||||||
import akka.http.scaladsl.{ TestUtils, Http, ServerSettings }
|
import akka.http.scaladsl.{ TestUtils, Http }
|
||||||
import akka.http.impl.util.{ SingletonException, StreamUtils }
|
import akka.http.impl.util.{ SingletonException, StreamUtils }
|
||||||
import akka.util.ByteString
|
import akka.util.ByteString
|
||||||
import akka.stream.{ BidiShape, ActorFlowMaterializer }
|
import akka.stream.{ BidiShape, ActorFlowMaterializer }
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
import java.lang.{ StringBuilder ⇒ JStringBuilder }
|
||||||
|
import akka.http.ParserSettings
|
||||||
import com.typesafe.config.{ ConfigFactory, Config }
|
import com.typesafe.config.{ ConfigFactory, Config }
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.util.Random
|
import scala.util.Random
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
import akka.actor.ActorSystem
|
import akka.actor.ActorSystem
|
||||||
|
import akka.http.ParserSettings
|
||||||
import com.typesafe.config.{ ConfigFactory, Config }
|
import com.typesafe.config.{ ConfigFactory, Config }
|
||||||
|
|
||||||
object HttpHeaderParserTestBed extends App {
|
object HttpHeaderParserTestBed extends App {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
|
import akka.http.ParserSettings
|
||||||
import akka.http.scaladsl.util.FastFuture
|
import akka.http.scaladsl.util.FastFuture
|
||||||
import com.typesafe.config.{ ConfigFactory, Config }
|
import com.typesafe.config.{ ConfigFactory, Config }
|
||||||
import scala.concurrent.Future
|
import scala.concurrent.Future
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.parsing
|
package akka.http.impl.engine.parsing
|
||||||
|
|
||||||
|
import akka.http.ParserSettings
|
||||||
import akka.http.scaladsl.util.FastFuture
|
import akka.http.scaladsl.util.FastFuture
|
||||||
import com.typesafe.config.{ ConfigFactory, Config }
|
import com.typesafe.config.{ ConfigFactory, Config }
|
||||||
import scala.concurrent.{ Future, Await }
|
import scala.concurrent.{ Future, Await }
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
package akka.http.impl.engine.server
|
package akka.http.impl.engine.server
|
||||||
|
|
||||||
|
import akka.http.ServerSettings
|
||||||
|
|
||||||
import scala.util.Random
|
import scala.util.Random
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.concurrent.duration._
|
import scala.concurrent.duration._
|
||||||
|
|
@ -13,7 +15,6 @@ import akka.util.ByteString
|
||||||
import akka.stream.scaladsl._
|
import akka.stream.scaladsl._
|
||||||
import akka.stream.ActorFlowMaterializer
|
import akka.stream.ActorFlowMaterializer
|
||||||
import akka.stream.testkit._
|
import akka.stream.testkit._
|
||||||
import akka.http.scaladsl.ServerSettings
|
|
||||||
import akka.http.scaladsl.model._
|
import akka.http.scaladsl.model._
|
||||||
import akka.http.impl.util._
|
import akka.http.impl.util._
|
||||||
import headers._
|
import headers._
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ package akka.http.scaladsl
|
||||||
|
|
||||||
import java.io.{ BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter }
|
import java.io.{ BufferedReader, BufferedWriter, InputStreamReader, OutputStreamWriter }
|
||||||
import java.net.Socket
|
import java.net.Socket
|
||||||
|
import akka.http.ServerSettings
|
||||||
import com.typesafe.config.{ Config, ConfigFactory }
|
import com.typesafe.config.{ Config, ConfigFactory }
|
||||||
import scala.annotation.tailrec
|
import scala.annotation.tailrec
|
||||||
import scala.concurrent.Await
|
import scala.concurrent.Await
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue