Packages

class HttpExt extends Extension

Akka extension for HTTP which serves as the main entry point into akka-http.

Use as Http().bindAndHandle etc. with an implicit ActorSystem in scope.

Annotations
@DoNotInherit()
Source
Http.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. HttpExt
  2. Extension
  3. AnyRef
  4. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. type ClientLayer = BidiFlow[HttpRequest, SslTlsOutbound, SslTlsInbound, HttpResponse, NotUsed]
  2. type ServerLayer = BidiFlow[HttpResponse, SslTlsOutbound, SslTlsInbound, HttpRequest, NotUsed]

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from HttpExt toany2stringadd[HttpExt] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  4. def ->[B](y: B): (HttpExt, B)
    Implicit
    This member is added by an implicit conversion from HttpExt toArrowAssoc[HttpExt] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def cachedHostConnectionPool[T](host: String, port: Int = 80, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log): Flow[(HttpRequest, T), (Try[HttpResponse], T), HostConnectionPool]

    Returns a akka.stream.scaladsl.Flow which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint.

    Returns a akka.stream.scaladsl.Flow which dispatches incoming HTTP requests to the per-ActorSystem pool of outgoing HTTP connections to the given target host endpoint. For every ActorSystem, target host and pool configuration a separate connection pool is maintained. The HTTP layer transparently manages idle shutdown and restarting of connections pools as configured. The returned akka.stream.scaladsl.Flow instances therefore remain valid throughout the lifetime of the application.

    The internal caching logic guarantees that there will never be more than a single pool running for the given target host endpoint and configuration (in this ActorSystem).

    Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type T from the application which is emitted together with the corresponding response.

    To configure additional settings for the pool (and requests made using it), use the akka.http.host-connection-pool config section or pass in a ConnectionPoolSettings explicitly.

  8. def cachedHostConnectionPoolHttps[T](host: String, port: Int = 443, connectionContext: HttpsConnectionContext = defaultClientHttpsContext, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log): Flow[(HttpRequest, T), (Try[HttpResponse], T), HostConnectionPool]

    Same as #cachedHostConnectionPool but for encrypted (HTTPS) connections.

    Same as #cachedHostConnectionPool but for encrypted (HTTPS) connections.

    If an explicit ConnectionContext is given then it rather than the configured default ConnectionContext will be used for encryption on the connections.

    To configure additional settings for the pool (and requests made using it), use the akka.http.host-connection-pool config section or pass in a ConnectionPoolSettings explicitly.

  9. def clientLayer(hostHeader: Host, settings: ClientConnectionSettings, log: LoggingAdapter = system.log): ClientLayer

    Constructs a akka.http.scaladsl.Http.ClientLayer stage using the given akka.http.scaladsl.settings.ClientConnectionSettings.

  10. def clientLayer(hostHeader: Host): ClientLayer

    Constructs a akka.http.scaladsl.Http.ClientLayer stage using the configured default akka.http.scaladsl.settings.ClientConnectionSettings, configured using the akka.http.client config section.

  11. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  12. def connectionTo(host: String): OutgoingConnectionBuilder

    Creates a builder which will create a single connection to a host every time the built flow is materialized.

    Creates a builder which will create a single connection to a host every time the built flow is materialized. There is no pooling and you are yourself responsible for lifecycle management of the connection. For a more convenient Request level API see singleRequest()

    returns

    A builder to configure more specific setup for the connection and then build a Flow[Request, Response, Future[OutgoingConnection]].

  13. def defaultClientHttpsContext: HttpsConnectionContext

    Gets the current default client-side HttpsConnectionContext.

    Gets the current default client-side HttpsConnectionContext. Defaults used here can be configured using ssl-config or the context can be replaced using setDefaultClientHttpsContext

  14. def ensuring(cond: (HttpExt) => Boolean, msg: => Any): HttpExt
    Implicit
    This member is added by an implicit conversion from HttpExt toEnsuring[HttpExt] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  15. def ensuring(cond: (HttpExt) => Boolean): HttpExt
    Implicit
    This member is added by an implicit conversion from HttpExt toEnsuring[HttpExt] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  16. def ensuring(cond: Boolean, msg: => Any): HttpExt
    Implicit
    This member is added by an implicit conversion from HttpExt toEnsuring[HttpExt] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  17. def ensuring(cond: Boolean): HttpExt
    Implicit
    This member is added by an implicit conversion from HttpExt toEnsuring[HttpExt] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  18. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  20. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  21. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  22. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  23. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  24. def newHostConnectionPool[T](host: String, port: Int = 80, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log)(implicit fm: Materializer): Flow[(HttpRequest, T), (Try[HttpResponse], T), HostConnectionPool]

    Starts a new connection pool to the given host and configuration and returns a akka.stream.scaladsl.Flow which dispatches the requests from all its materializations across this pool.

    Starts a new connection pool to the given host and configuration and returns a akka.stream.scaladsl.Flow which dispatches the requests from all its materializations across this pool. While the started host connection pool internally shuts itself down automatically after the configured idle timeout it will spin itself up again if more requests arrive from an existing or a new client flow materialization. The returned flow therefore remains usable for the full lifetime of the application.

    Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type T from the application which is emitted together with the corresponding response.

    To configure additional settings for the pool (and requests made using it), use the akka.http.host-connection-pool config section or pass in a ConnectionPoolSettings explicitly.

  25. def newHostConnectionPoolHttps[T](host: String, port: Int = 443, connectionContext: HttpsConnectionContext = defaultClientHttpsContext, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log)(implicit fm: Materializer): Flow[(HttpRequest, T), (Try[HttpResponse], T), HostConnectionPool]

    Same as #newHostConnectionPool but for encrypted (HTTPS) connections.

    Same as #newHostConnectionPool but for encrypted (HTTPS) connections.

    If an explicit ConnectionContext is given then it rather than the configured default ConnectionContext will be used for encryption on the connections.

    To configure additional settings for the pool (and requests made using it), use the akka.http.host-connection-pool config section or pass in a ConnectionPoolSettings explicitly.

  26. def newServerAt(interface: String, port: Int): ServerBuilder

    Main entry point to create a server binding.

    Main entry point to create a server binding.

    interface

    The interface to bind to.

    port

    The port to bind to or 0 if the port should be automatically assigned.

  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  29. def outgoingConnection(host: String, port: Int = 80, localAddress: Option[InetSocketAddress] = None, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log): Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]]

    Creates a akka.stream.scaladsl.Flow representing a prospective HTTP client connection to the given endpoint.

    Creates a akka.stream.scaladsl.Flow representing a prospective HTTP client connection to the given endpoint. Every materialization of the produced flow will attempt to establish a new outgoing connection.

    To configure additional settings for requests made using this method, use the akka.http.client config section or pass in a akka.http.scaladsl.settings.ClientConnectionSettings explicitly.

    Prefer connectionTo over this method.

  30. def outgoingConnectionHttps(host: String, port: Int = 443, connectionContext: HttpsConnectionContext = defaultClientHttpsContext, localAddress: Option[InetSocketAddress] = None, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log): Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]]

    Same as #outgoingConnection but for encrypted (HTTPS) connections.

    Same as #outgoingConnection but for encrypted (HTTPS) connections.

    If an explicit HttpsConnectionContext is given then it rather than the configured default HttpsConnectionContext will be used for encryption on the connection.

    To configure additional settings for requests made using this method, use the akka.http.client config section or pass in a akka.http.scaladsl.settings.ClientConnectionSettings explicitly.

    Prefer connectionTo over this method.

  31. def outgoingConnectionUsingContext(host: String, port: Int, connectionContext: ConnectionContext, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log): Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]]

    Similar to outgoingConnection but allows to specify a user-defined context to run the connection on.

    Similar to outgoingConnection but allows to specify a user-defined context to run the connection on.

    Depending on the kind of ConnectionContext the implementation will add TLS between the given transport and the HTTP implementation

    To configure additional settings for requests made using this method, use the akka.http.client config section or pass in a akka.http.scaladsl.settings.ClientConnectionSettings explicitly.

    Prefer connectionTo over this method.

  32. def serverLayer(settings: ServerSettings = ServerSettings(system), remoteAddress: Option[InetSocketAddress] = None, log: LoggingAdapter = system.log, isSecureConnection: Boolean = false): ServerLayer

    Constructs a akka.http.scaladsl.Http.ServerLayer stage using the given akka.http.scaladsl.settings.ServerSettings.

    Constructs a akka.http.scaladsl.Http.ServerLayer stage using the given akka.http.scaladsl.settings.ServerSettings. The returned akka.stream.scaladsl.BidiFlow isn't reusable and can only be materialized once. The remoteAddress, if provided, will be added as a header to each akka.http.scaladsl.model.HttpRequest this layer produces if the akka.http.server.remote-address-header configuration option is enabled.

  33. def setDefaultClientHttpsContext(context: HttpsConnectionContext): Unit

    Sets the default client-side HttpsConnectionContext.

  34. def shutdownAllConnectionPools(): Future[Unit]

    Triggers an orderly shutdown of all host connections pools currently maintained by the akka.actor.ActorSystem.

    Triggers an orderly shutdown of all host connections pools currently maintained by the akka.actor.ActorSystem. The returned future is completed when all pools that were live at the time of this method call have completed their shutdown process.

    If existing pool client flows are re-used or new ones materialized concurrently with or after this method call the respective connection pools will be restarted and not contribute to the returned future.

  35. def singleRequest(request: HttpRequest, connectionContext: HttpsConnectionContext = defaultClientHttpsContext, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log): Future[HttpResponse]

    Fires a single akka.http.scaladsl.model.HttpRequest across the (cached) host connection pool for the request's effective URI to produce a response future.

    Fires a single akka.http.scaladsl.model.HttpRequest across the (cached) host connection pool for the request's effective URI to produce a response future.

    If an explicit ConnectionContext is given then it rather than the configured default ConnectionContext will be used for setting up the HTTPS connection pool, if the request is targeted towards an https endpoint.

    Note that the request must have an absolute URI, otherwise the future will be completed with an error.

  36. def singleWebSocketRequest[T](request: WebSocketRequest, clientFlow: Flow[Message, Message, T], connectionContext: ConnectionContext = defaultClientHttpsContext, localAddress: Option[InetSocketAddress] = None, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log)(implicit mat: Materializer): (Future[WebSocketUpgradeResponse], T)

    Runs a single WebSocket conversation given a Uri and a flow that represents the client side of the WebSocket conversation.

  37. def superPool[T](connectionContext: HttpsConnectionContext = defaultClientHttpsContext, settings: ConnectionPoolSettings = defaultConnectionPoolSettings, log: LoggingAdapter = system.log): Flow[(HttpRequest, T), (Try[HttpResponse], T), NotUsed]

    Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs.

    Creates a new "super connection pool flow", which routes incoming requests to a (cached) host connection pool depending on their respective effective URIs. Note that incoming requests must have an absolute URI.

    If an explicit ConnectionContext is given then it rather than the configured default ConnectionContext will be used for setting up HTTPS connection pools, if required.

    Since the underlying transport usually comprises more than a single connection the produced flow might generate responses in an order that doesn't directly match the consumed requests. For example, if two requests A and B enter the flow in that order the response for B might be produced before the response for A. In order to allow for easy response-to-request association the flow takes in a custom, opaque context object of type T from the application which is emitted together with the corresponding response.

    To configure additional settings for the pool (and requests made using it), use the akka.http.host-connection-pool config section or pass in a ConnectionPoolSettings explicitly.

  38. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  39. implicit val system: ExtendedActorSystem
  40. def toString(): String
    Definition Classes
    AnyRef → Any
  41. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  42. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  43. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  44. def webSocketClientFlow(request: WebSocketRequest, connectionContext: ConnectionContext = defaultClientHttpsContext, localAddress: Option[InetSocketAddress] = None, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log): Flow[Message, Message, Future[WebSocketUpgradeResponse]]

    Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.

    Constructs a flow that once materialized establishes a WebSocket connection to the given Uri.

    The layer is not reusable and must only be materialized once.

  45. def webSocketClientLayer(request: WebSocketRequest, settings: ClientConnectionSettings = ClientConnectionSettings(system), log: LoggingAdapter = system.log): WebSocketClientLayer

    Constructs a akka.http.scaladsl.Http.WebSocketClientLayer stage using the configured default akka.http.scaladsl.settings.ClientConnectionSettings, configured using the akka.http.client config section.

    Constructs a akka.http.scaladsl.Http.WebSocketClientLayer stage using the configured default akka.http.scaladsl.settings.ClientConnectionSettings, configured using the akka.http.client config section.

    The layer is not reusable and must only be materialized once.

Deprecated Value Members

  1. def bind(interface: String, port: Int = DefaultPortForProtocol, connectionContext: ConnectionContext = defaultServerHttpContext, settings: ServerSettings = ServerSettings(system), log: LoggingAdapter = system.log): Source[IncomingConnection, Future[ServerBinding]]

    Creates a akka.stream.scaladsl.Source of akka.http.scaladsl.Http.IncomingConnection instances which represents a prospective HTTP server binding on the given endpoint.

    Creates a akka.stream.scaladsl.Source of akka.http.scaladsl.Http.IncomingConnection instances which represents a prospective HTTP server binding on the given endpoint.

    If the given port is 0 the resulting source can be materialized several times. Each materialization will then be assigned a new local port by the operating system, which can then be retrieved by the materialized akka.http.scaladsl.Http.ServerBinding.

    If the given port is non-zero subsequent materialization attempts of the produced source will immediately fail, unless the first materialization has already been unbound. Unbinding can be triggered via the materialized akka.http.scaladsl.Http.ServerBinding.

    If an ConnectionContext is given it will be used for setting up TLS encryption on the binding. Otherwise the binding will be unencrypted.

    If no port is explicitly given (or the port value is negative) the protocol's default port will be used, which is 80 for HTTP and 443 for HTTPS.

    To configure additional settings for a server started using this method, use the akka.http.server config section or pass in a akka.http.scaladsl.settings.ServerSettings explicitly.

    Annotations
    @deprecated
    Deprecated

    (Since version 10.2.0) Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding.

  2. def bindAndHandle(handler: Flow[HttpRequest, HttpResponse, Any], interface: String, port: Int = DefaultPortForProtocol, connectionContext: ConnectionContext = defaultServerHttpContext, settings: ServerSettings = ServerSettings(system), log: LoggingAdapter = system.log)(implicit fm: Materializer = systemMaterializer): Future[ServerBinding]

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    The number of concurrently accepted connections can be configured by overriding the akka.http.server.max-connections setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.

    To configure additional settings for a server started using this method, use the akka.http.server config section or pass in a akka.http.scaladsl.settings.ServerSettings explicitly.

    Annotations
    @deprecated @nowarn()
    Deprecated

    (Since version 10.2.0) Use Http().newServerAt(...)...bindFlow() to create server bindings.

  3. def bindAndHandleAsync(handler: (HttpRequest) => Future[HttpResponse], interface: String, port: Int = DefaultPortForProtocol, connectionContext: ConnectionContext = defaultServerHttpContext, settings: ServerSettings = ServerSettings(system), parallelism: Int = 0, log: LoggingAdapter = system.log)(implicit fm: Materializer = systemMaterializer): Future[ServerBinding]

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    The number of concurrently accepted connections can be configured by overriding the akka.http.server.max-connections setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.

    To configure additional settings for a server started using this method, use the akka.http.server config section or pass in a akka.http.scaladsl.settings.ServerSettings explicitly.

    Parameter parallelism specifies how many requests are attempted to be handled concurrently per connection. In HTTP/1 this makes only sense if HTTP pipelining is enabled (which is not recommended). The default value of 0 means that the value is taken from the akka.http.server.pipelining-limit setting from the configuration. In HTTP/2, the default value is taken from akka.http.server.http2.max-concurrent-streams.

    Any other value for parallelism overrides the setting.

    Annotations
    @deprecated
    Deprecated

    (Since version 10.2.0) Use Http().newServerAt(...)...bind() to create server bindings.

  4. def bindAndHandleSync(handler: (HttpRequest) => HttpResponse, interface: String, port: Int = DefaultPortForProtocol, connectionContext: ConnectionContext = defaultServerHttpContext, settings: ServerSettings = ServerSettings(system), log: LoggingAdapter = system.log)(implicit fm: Materializer = systemMaterializer): Future[ServerBinding]

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    Convenience method which starts a new HTTP server at the given endpoint and uses the given handler akka.stream.scaladsl.Flow for processing all incoming connections.

    The number of concurrently accepted connections can be configured by overriding the akka.http.server.max-connections setting. Please see the documentation in the reference.conf for more information about what kind of guarantees to expect.

    To configure additional settings for a server started using this method, use the akka.http.server config section or pass in a akka.http.scaladsl.settings.ServerSettings explicitly.

    Annotations
    @deprecated @nowarn()
    Deprecated

    (Since version 10.2.0) Use Http().newServerAt(...)...bindSync() to create server bindings.

  5. def defaultServerHttpContext: ConnectionContext

    Gets the current default server-side ConnectionContext – defaults to plain HTTP.

    Gets the current default server-side ConnectionContext – defaults to plain HTTP. Can be modified using setDefaultServerHttpContext, and will then apply for servers bound after that call has completed.

    Annotations
    @deprecated
    Deprecated

    (Since version 10.2.0) Set context explicitly when binding

  6. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

  7. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from HttpExt toStringFormat[HttpExt] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  8. def setDefaultServerHttpContext(context: ConnectionContext): Unit

    Sets the default server-side ConnectionContext.

    Sets the default server-side ConnectionContext. If it is an instance of HttpsConnectionContext then the server will be bound using HTTPS.

    Annotations
    @deprecated
    Deprecated

    (Since version 10.2.0) Set context explicitly when binding

  9. def [B](y: B): (HttpExt, B)
    Implicit
    This member is added by an implicit conversion from HttpExt toArrowAssoc[HttpExt] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from Extension

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion any2stringadd fromHttpExt to any2stringadd[HttpExt]

Inherited by implicit conversion StringFormat fromHttpExt to StringFormat[HttpExt]

Inherited by implicit conversion Ensuring fromHttpExt to Ensuring[HttpExt]

Inherited by implicit conversion ArrowAssoc fromHttpExt to ArrowAssoc[HttpExt]

Ungrouped