import jhttpserver.core.WebServer;
import jhttpserver.entity.Header;
import jhttpserver.entity.Request;
import jhttpserver.entity.Response;
import jhttpserver.interfaces.Execution;
import jhttpserver.interfaces.IMiddleWare;

import java.io.IOException;
import java.util.List;

/**
 * Created by jayin on 14/12/5.
 */
public class MiddleWareTest {


    public static void main(String[] args) throws IOException {
        WebServer app = new WebServer();
        app.use(new IMiddleWare() {
            @Override
            public void work(Request req, Response res) {
                System.out.println("-- middleware 1 works");
            }
        });

        app.use(new IMiddleWare() {
            @Override
            public void work(Request req, Response res) {
                System.out.println("-- middleware 2 works");
                List<Header> headers = req.getHeaders();
                for(Header h : headers){
                    System.out.println(h.toString());
                }

            }
        });

        app.get("/get", new Execution() {
            @Override
            public void onExecute(Request req, Response res) {
                res.send("Finish!");
            }
        });

        app.post("/post", new Execution() {
            @Override
            public void onExecute(Request req, Response res) {
                List<Header> headers = req.getHeaders();
                for(Header h : headers){
                    System.out.println(h.toString());
                }
//                res.send("233");
            }
        });

        app.listen(WebServer.DefaultPort);
    }
}

@@ -516,38 +516,43 @@
          public 
-void w
+boolean onW
 ork(Request req,
@@ -621,32 +621,61 @@
 ware 1 works%22);%0A
+                return true;%0A
             %7D%0A  
@@ -766,14 +766,19 @@
 lic 
-void w
+boolean onW
 ork(
@@ -1037,16 +1037,44 @@
       %7D%0A
+                return true;
 %0A       

add return