package fi.tekislauta;

import static spark.Spark.*;
import fi.tekislauta.db.*;
import com.google.gson.*;
import fi.tekislauta.models.Board;
import fi.tekislauta.models.Post;

public class Main {
    public static void main(String[] args) {
        port(1234);

        Gson gson = new Gson();

        Database db = new Database();
        get("/api", (req, res) -> {
            return db.executeQuery("SELECT * FROM Board");
        });

        get("/api/boards/:id", (req,res) -> {
            return db.executeQuery("SELECT * FROM Board WHERE abbreviation='" + req.params("id") + "'");
        });

        get("/api/posts/:id", (req,res) -> {
            return "Hello world!";
        });

        get("/api/test", (req, res) -> {
            Board b = new Board(1, "Koulu", "Kumpula", "uliopisto");
            b.addPost(new Post(1,1,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));


            b.addPost(new Post(2,2,12345,123,"Joonan kissa", "Joonan kissat ovat ruotsalaisia"));

            return gson.toJson(b);

        });
    }
}

@@ -724,32 +724,91 @@
 (req, res) -%3E %7B%0A
+            res.header(%22Content-Type%22,%22application/json%22);%0A
             Boar

Add JSON header to test method