https://github.com/luismanuelamengual/neogroup-httpserver
Simple and fast http server
https://github.com/luismanuelamengual/neogroup-httpserver
fast http server simple
Last synced: about 1 year ago
JSON representation
Simple and fast http server
- Host: GitHub
- URL: https://github.com/luismanuelamengual/neogroup-httpserver
- Owner: luismanuelamengual
- License: apache-2.0
- Created: 2016-12-13T13:54:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-16T19:30:08.000Z (almost 9 years ago)
- Last Synced: 2025-01-22T05:29:03.030Z (about 1 year ago)
- Topics: fast, http, server, simple
- Language: Java
- Homepage:
- Size: 227 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README







# NeoGroup-HttpServer
Fast Open-source HTTP server for modern operating systems. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
Getting started
---------------
For maven users, just add the following dependency
```xml
com.github.luismanuelamengual
NeoGroup-HttpServer
1.0
```
Examples
---------
Simple "hello world" example of a http server listening at port *80*
```java
package example;
import org.neogroup.httpserver.HttpServer;
import org.neogroup.httpserver.HttpResponse;
import org.neogroup.httpserver.contexts.HttpContext;
import java.util.concurrent.Executors;
public class Main {
public static void main(String[] args) {
HttpServer server = new HttpServer(80);
server.setExecutor(Executors.newCachedThreadPool());
server.addContext(new HttpContext("/test/") {
@Override
public HttpResponse onContext(HttpRequest request) {
HttpResponse response = new HttpResponse();
response.write("Hello world !!");
return response;
}
});
server.start();
}
}
```
Publishing classpath resources and files from a path folder
```java
package example;
import org.neogroup.httpserver.HttpServer;
import org.neogroup.httpserver.HttpResponse;
import org.neogroup.httpserver.contexts.HttpFolderContext;
import java.util.concurrent.Executors;
public class Main {
public static void main(String[] args) {
HttpServer server = new HttpServer(80);
server.setExecutor(Executors.newCachedThreadPool());
server.addContext(new HttpFolderContext("/resources/", "/home/luis/git/myproject/public/"));
server.addContext(new HttpFolderContext("/jar/", "${classPath}/"));
server.start();
}
}
```