// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.restapi;

import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;

import java.io.IOException;
import java.io.OutputStream;

/**
 * A 200 ok response with a message in JSON.
 *
 * @author bratseth
 */
public class MessageResponse extends HttpResponse {

    private final Slime slime = new Slime();

    public MessageResponse(String message) {
        super(200);
        slime.setObject().setString("message", message);
    }

    @Override
    public void render(OutputStream stream) throws IOException {
        new JsonFormat(true).encode(stream, slime);
    }

    @Override
    public String getContentType() { return "application/json"; }

}

@@ -161,159 +161,19 @@
 hoo.
-container.jdisc.HttpResponse;%0Aimport com.yahoo.slime.JsonFormat;%0Aimport com.yahoo.slime.Slime;%0A%0Aimport java.io.IOException;%0Aimport java.io.OutputStream
+slime.Slime
 ;%0A%0A/
@@ -288,12 +288,17 @@
 nds 
-Http
+SlimeJson
 Resp
@@ -309,54 +309,8 @@
  %7B%0A%0A
-    private final Slime slime = new Slime();%0A%0A
     
@@ -368,293 +368,196 @@
 per(
-200);%0A        slime.setObject().setString(%22message%22, message);%0A    %7D%0A%0A    @Override%0A    public void render(OutputStream stream) throws IOException %7B%0A        new JsonFormat(true).encode(stream, s
+slime(message));%0A    %7D%0A%0A    private static Slime slime(String message) %7B%0A        var slime = new S
 lime
+(
 );%0A    
-%7D%0A%0A
     
-@Override%0A    public String getContentType() %7B return %22application/json%22;
+slime.setObject().setString(%22message%22, message);%0A        return slime;%0A   
  %7D%0A%0A

Simplify MessageResponse