# Quick Start

You have your REST API ready to serve JSON in less than ten lines of code

import com.jinyframework.*;
import com.google.gson.Gson;

public class Main {
   public static void main(String args[]) {
       val server = HTTPServer.port(1234);
       val gson = new Gson();
       server.useTransformer(gson::toJson);
       server.get("/ping", ctx -> HttpResponse.of("Pong"));
       server.start();
   }
} 
What is ctx -> HttpResponse.of("Pong") ?

This is called Functional Interface(opens new window) - a shorthand syntax of Java 8, if you use Java 7 and before, you can write like this:

server.use("/", new Handler() {
    @Override
    public HttpResponse handleFunc(Context context) throws Exception {
        return HttpResponse.of("Hello World!");
    }
});
Okay, then what is gson::toJson ?

It's another sugar syntax called Double Colon Operator(opens new window)

The code above can be written without Double Colon Operator like this:

server.useTransformer(response -> gson.toJson(response));

or without Double Colon Operator and Functional Interface should be as follows:

server.useTransformer(new RequestTransformer() {
    @Override
    public String render(Object model) {
        return gson.toJson(model);
    }
});