Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mike10004/nanohttpd-champion
Tools to use NanoHTTPD like a champ.
https://github.com/mike10004/nanohttpd-champion
Last synced: 10 days ago
JSON representation
Tools to use NanoHTTPD like a champ.
- Host: GitHub
- URL: https://github.com/mike10004/nanohttpd-champion
- Owner: mike10004
- License: mit
- Created: 2017-10-18T17:10:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-09-13T20:56:50.000Z (over 3 years ago)
- Last Synced: 2024-10-29T14:13:19.569Z (2 months ago)
- Language: Java
- Size: 101 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Travis build status](https://travis-ci.org/mike10004/nanohttpd-champion.svg?branch=master)](https://travis-ci.org/mike10004/nanohttpd-champion)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/gh1tuv64urbhfldb?svg=true)](https://ci.appveyor.com/project/mike10004/nanohttpd-champion)
[![Maven Central](https://img.shields.io/maven-central/v/com.github.mike10004/nanohttpd-champion.svg)](https://repo1.maven.org/maven2/com/github/mike10004/nanohttpd-champion/)# nanohttpd-champion
Use [NanoHTTPD](https://github.com/NanoHttpd/nanohttpd) like a champion.
## Maven
com.github.mike10004
nanohttpd-server
0.14
## Usage
import java.io.InputStream;
import java.nio.charset.Charset;
import io.github.mike10004.nanochamp.server.NanoControl;
import io.github.mike10004.nanochamp.server.NanoResponse;
import io.github.mike10004.nanochamp.server.NanoServer;public class NanoServerExample {
public static void main(String[] args) throws Exception {
Charset charset = Charset.forName("UTF-8");
NanoServer server = NanoServer.builder()
.get(request -> NanoResponse.status(200).plainText("hello, world", charset))
.build();
try (NanoControl control = server.startServer();
InputStream in = control.baseUri().toURL().openStream()) {
byte[] buffer = new byte[1024];
int r = in.read(buffer);
String content = new String(buffer, 0, r, charset);
System.out.println(content); // hello, world
}
}
}