Created
January 21, 2020 10:27
-
-
Save bibarsov/10fa78b9c47cd2b898127ace22f5a89f to your computer and use it in GitHub Desktop.
Nginx-Closure Example
This file contains hidden or 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
import nginx.clojure.java.ArrayMap; | |
import nginx.clojure.java.NginxJavaRingHandler; | |
import java.io.IOException; | |
import java.util.Map; | |
import static nginx.clojure.MiniConstants.CONTENT_TYPE; | |
import static nginx.clojure.MiniConstants.NGX_HTTP_OK; | |
public class TestRingHandler implements NginxJavaRingHandler { | |
private int counter = 0; | |
@Override | |
public Object[] invoke(Map<String, Object> req) throws IOException { | |
return new Object[]{ | |
NGX_HTTP_OK, //http status 200 | |
ArrayMap.create( | |
CONTENT_TYPE, "text/plain", | |
"X-Header", "foobar" | |
), //headers map | |
"Hello, Java & Nginx! Counter: " + (counter++) | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nginx.conf
build.gradle for app.jar