Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/amayaframework/sun-http-server

A repackaged and refactored sun http server, created in the original form by Oracle and formerly embedded in the jdk. Distributed under the GNU v2 license.
https://github.com/amayaframework/sun-http-server

http http-server https https-server java java-8 java-library java-nio java-server nonblocking-sockets sun sun-server

Last synced: about 1 month ago
JSON representation

A repackaged and refactored sun http server, created in the original form by Oracle and formerly embedded in the jdk. Distributed under the GNU v2 license.

Awesome Lists containing this project

README

        

# sun-http-server [![maven-central](https://img.shields.io/maven-central/v/io.github.amayaframework/http-server?color=blue)](https://repo1.maven.org/maven2/io/github/amayaframework/http-server/)

A repackaged and refactored sun http server, created in the original form by Oracle and formerly embedded in the jdk.
Distributed under the GNU v2 license.

This server, built on non-blocking sockets, is a really good lightweight solution that has everything you need
for full use in various projects. Up to this point, it was ignored by most of the community due to its location
in sun packages. Now this restriction has been removed.

## Getting Started

To install it, you will need:

* Java 8+
* SLF4J implementation (optional)
* Maven/Gradle

## Installing

### Gradle dependency

```Groovy
dependencies {
implementation group: 'io.github.amayaframework', name: 'http-server', version: 'LATEST'
}
```

### Maven dependency

```

io.github.amayaframework
http-server
LATEST

```

## Usage example

The code below will start the server associated with the address localhost:8000.
There will be one handler on the server responding to a route starting with /hello.
The response will contain code 200 and an empty body.
He will respond to all other requests with the code 404.

```Java
public class Server {
public static void main(String[] args) throws IOException {
HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0);
server.createContext("/hello", exchange -> {
exchange.sendResponseHeaders(HttpCode.OK, 0);
exchange.close();
});
server.start();
}
}
```

## Built With

* [Gradle](https://gradle.org) - Dependency management
* [slf4j](https://www.slf4j.org) - Logging facade

## Authors

* [Oracle Corporation](https://www.oracle.com) - *Main work*
* [RomanQed](https://github.com/RomanQed) - *Repackaging and refactoring*

See also the list of [contributors](https://github.com/AmayaFramework/sun-http-server/contributors) who participated in
this project.

## License

This project is licensed under the GNU GENERAL PUBLIC LICENSE Version 2 - see the [LICENSE](LICENSE) file for details

Also, according to the requirements, the original inserts of Oracle
license headers are preserved in the original source files.

## Acknowledgments

Thanks to all the sun developers who participated in the creation of this server.