/**
 * Created by Siclait on 18/7/16.
 */
import JSONTools.ResponseError;

import static JSONTools.JSONUtil.json;
import static spark.Spark.after;
import static spark.Spark.get;

public class JSONServiceController {

    public JSONServiceController() {
        // Fetch All Urls
        get("/json/allurls", (req, res) -> DatabaseManager.FetchAllURL(), json());

        // Fetch Specific Short Url
        get("/json/original/:short",  (req, res) -> {
            String shortURL = req.params(":short");

            String url = DatabaseManager.FetchOriginalURL(shortURL);

            if(url != null)
                return url;

            res.status(400);
            return new ResponseError("No url with id %s found", shortURL);

        }, json());

        after("/json/*",(req, res) -> {res.type("application/json");});
    }
}


@@ -35,16 +35,36 @@
 16.%0A */%0A
+import Entity.User;%0A
 import J
@@ -86,16 +86,47 @@
 seError;
+%0Aimport org.h2.engine.Database;
 %0A%0Aimport
@@ -796,32 +796,533 @@
    %7D, json());%0A%0A
+        // Fetch All Users%0A        get(%22/json/allusers%22, (req, res) -%3E DatabaseManager.FetchAllUsers(), json());%0A%0A        // Fetch Specific User%0A        get(%22/json/user/:username%22, (req, res) -%3E %7B%0A            String username = req.params(%22:username%22);%0A%0A            User user = DatabaseManager.FetchUser(username);%0A%0A            if(user != null)%0A                return user;%0A%0A            res.status(400);%0A            return new ResponseError(%22No user with id %25s found%22, username);%0A%0A        %7D, json());%0A%0A
         after(%22/

Add find User json function