[ANN] Nginx-Clojure v0.4.1 Release!

xfeep nginx-forum at nginx.us
Wed Aug 12 18:21:28 UTC 2015


0.4.1 (2015-08-12)

New Feature: Coroutine based socket supports unix domain socket
New Feature: APIs for Embedding Nginx-Clojure into a standard
Clojure/Java/Groovy App (issue #86). This feature makes debug/test with
Nginx Clojure/Java/Groovy handlers very easy.
New Feature: Autodetect jvm_path (issue #85)
New Feature: Support to use annotation to mark a class or method to be
suspenable in coroutine context (issue #84)
Enhancement: Auto send error when meets a non websocket request with
auto_upgrade_wsis on
Enhancement: Add websocket-upgrade! to server channel API
Enhancement: Add WholeMessageAdapter to make handling small websocket
messages easier.
Bug Fix: NginxHttpServerChannel.write(ByteBuffer buf) does not reset the
buffer's position (issue #83)
Bug Fix: No access to tomcat server 8.24 from nginx-clojure (issue #82)
Binaries Distribution: Including some java sources for easy debug.
Build Script: Autodetect JNI header files

Below are some simple examples about embedding Nginx-Clojure and we can try
them with  lein repl or debug them in a Java IDE.

[nginx-clojure/nginx-clojure-embed "0.4.1"]

For Clojure

    ;;(1) Start it with ring handler and an options map
    ;;my-app can be a simple ring hanler or a compojure router.
    (run-server my-app {:port 8080})


   ;;(2) Start it with a nginx.conf file
    (run-server "/my-dir/nginx.conf")

   ;;(3) Start it with a given work dir
    (binding [*nginx-work-dir* my-work-dir]
      (run-server ...))

   ;;(4) Stop the server
    (stop-server)

For Java

//Start it with ring handler and an options map
NginxEmbedServer.getServer().start("my.HelloHandler",
ArrayMap.create("port", "8081"));


//Start it with with a nginx.conf file
NginxEmbedServer.getServer().start("/my-dir/nginx.conf");

//Start it with a given work dir
NginxEmbedServer.getServer().setWorkDir(my-work-dir);
NginxEmbedServer.getServer().start(...);


//Stop the server
NginxEmbedServer.getServer().stop();
default options:

          "error-log", "logs/error.log",
          "max-connections", "1024",
          "access-log", "off",
          "keepalive-timeout", "65",
          "max-threads", "8",
          "host", "0.0.0.0",
          "port", "8080",

There 's an example about compojure routing and websocket example in the
unit tests source : 

Clojure:
https://github.com/nginx-clojure/nginx-clojure/blob/master/nginx-clojure-embed/test/clojure/nginx/clojure/test_embed.clj

Java:
https://github.com/nginx-clojure/nginx-clojure/blob/master/nginx-clojure-embed/test/java/nginx/clojure/embed/JavaHandlersTest.java

Web Site   http://nginx-clojure.github.io/
Source Hosted on Github https://github.com/nginx-clojure/nginx-clojure
Google Group (mailing list)
https://groups.google.com/forum/#!forum/nginx-clojure

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,260968,260968#msg-260968



More information about the nginx mailing list