///////////////////////////////////////////////////////////////////////////////

    Copyright (c) 2018, 2019 Oracle and/or its affiliates. All rights reserved.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

///////////////////////////////////////////////////////////////////////////////

= WebServer Introduction
:pagename: webserver-introduction
:description: Helidon Reactive WebServer Introduction
:keywords: helidon, reactive, reactive streams, reactive java, reactive webserver

WebServer provides an asynchonous and reactive API for creating web applications. 
The API is inspired by popular NodeJS and Java frameworks.

== Quick Start

Here is the code for a minimalist web application that runs on a random free port:

[source,java]
----
    public static void main(String[] args) throws Exception {
        WebServer webServer = WebServer
                .create(Routing.builder()
                        .any((req, res) -> res.send("It works!")) // <1>
                        .build())
                .start() // <2>
                .toCompletableFuture()
                .get(10, TimeUnit.SECONDS); // <3>

        System.out.println("Server started at: http://localhost:" + webServer.port()); // <4>
    }
----

<1> For any kind of request, at any path, respond with `It works!`.
<2> Start the server.
<3> Wait for the server to start while throwing possible errors as exceptions.
<4> The server is bound to a random free port.

== Maven Coordinates

The <<about/04_managing-dependencies.adoc, Managing Dependencies>> page describes how you
should declare dependency management for Helidon applications. Then declare the following dependency in your project:

[source,xml,subs="verbatim,attributes"]
----
<dependency>
    <groupId>io.helidon.webserver</groupId>
    <artifactId>helidon-webserver</artifactId> <!--1-->
</dependency>
----

<1> Dependency on WebServer.
