blob: 3efd50fade619842a5b01700d63c2d2e4a1b11cf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http.v2;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.config.server.http.HttpConfigResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
/**
* Response that lists applications.
*
* @author lulf
* @since 5.1
*/
public class ListApplicationsResponse extends HttpResponse {
private final Slime slime = new Slime();
public ListApplicationsResponse(int status, Collection<String> applications) {
super(status);
Cursor array = slime.setArray();
for (String url : applications) {
array.addString(url);
}
}
@Override
public void render(OutputStream outputStream) throws IOException {
new JsonFormat(true).encode(outputStream, slime);
}
@Override
public String getContentType() {
return HttpConfigResponse.JSON_CONTENT_TYPE;
}
}
|