Commits

Vetle Leinonen-Roeim committed 4955fe6

Changed the required function definition for the methods that serves paths, so it should be a little less verbose.

  • Participants
  • Parent commits b8dab6d

Comments (0)

Files changed (4)

 
     :::scala
     class TestServer extends MiniHttpServer {
-      get("/")((exchange: HttpExchange) => {
+      get("/") { exchange => 
         exchange.getResponseHeaders().add("Content-type", "text/html")
         "It works!"
-      })
+      }
 
-      get("/foo")((exchange: HttpExchange) => {
+      get("/foo") { exchange =>
         exchange.getResponseHeaders().add("Content-type", "text/plain")
         "And here's foo."
-      })
+      }
     }
 
 After this, it needs to be started, as follows:
 
 organization := "net.roeim.minihttpserver"
 
-version := "0.1"
+version := "0.1.1"
 
 scalaVersion := "2.9.2"
 

src/main/scala/net/roeim/minihttpserver/MiniHttpServer.scala

    * get("/monkey") ((exchange: HttpExchange) => { "foo" }
    * </code>
    */
-  def get(path: String)(action: (HttpExchange) => Any) = mappings += path -> ((exchange: HttpExchange) => action(exchange))
+  def get(path: String)(action: HttpExchange => Any) = mappings += path -> action
 
   /**
    * Handle a HTTP request

src/test/scala/net/roeim/minihttpsrver/MiniHttpServerTest.scala

 
   // Define a test server that has a few pages we can test against
   class TestServer extends MiniHttpServer {
-    get("/")((exchange: HttpExchange) => {
+    get("/") { exchange =>
       exchange.getResponseHeaders().add("Content-type", "text/html")
       "It works!"
-    })
+    }
 
-    get("/foo")((exchange: HttpExchange) => {
+    get("/foo") { exchange =>
       exchange.getResponseHeaders().add("Content-type", "text/plain")
       "And here's foo."
-    })
+    }
   }
 
   var server: TestServer = new TestServer