Created
February 12, 2022 21:30
-
-
Save ebarlas/d932bda5901c2907596cc53bd89c781a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test; | |
import microhttp.EventLoop; | |
import microhttp.Header; | |
import microhttp.LogEntry; | |
import microhttp.Logger; | |
import microhttp.Options; | |
import microhttp.Response; | |
import java.io.IOException; | |
import java.util.List; | |
public class ThroughputServer { | |
public static void main(String[] args) throws IOException { | |
Response response = new Response( | |
200, | |
"OK", | |
List.of(new Header("Content-Type", "text/plain")), | |
"hello world\n".getBytes()); | |
Options options = new Options() | |
.withHost(args[0]) | |
.withAcceptLength(Integer.parseInt(args[1])); | |
Logger logger = new NoOpLogger(); | |
EventLoop eventLoop = new EventLoop(options, logger, (req, callback) -> callback.accept(response)); | |
eventLoop.start(); | |
} | |
static class NoOpLogger implements Logger { | |
@Override | |
public boolean enabled() { | |
return false; | |
} | |
@Override | |
public void log(LogEntry... entries) { | |
} | |
@Override | |
public void log(Exception e, LogEntry... entries) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment