Files
helidon/docs/se/webserver/01_introduction.adoc
Romain Grecourt 90ee65f33c Fix h1Prefix to SE and MP for all pages under /se and /mp respectively. (#2074)
Fix various links and formatting issues across the docs.
2020-06-19 14:25:55 -07:00

65 lines
2.3 KiB
Plaintext

///////////////////////////////////////////////////////////////////////////////
Copyright (c) 2018, 2020 Oracle and/or its affiliates.
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
:h1Prefix: SE
:pagename: webserver-introduction
:description: Helidon Reactive WebServer Introduction
:keywords: helidon, reactive, reactive streams, reactive java, reactive webserver
WebServer provides an asynchronous 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) {
WebServer webServer = WebServer
.create(Routing.builder()
.any((req, res) -> res.send("It works!"))) // <1>
.start() // <2>
.await(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 runtime 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.