Skip to content

Commit 3307282

Browse files
Add BannerController
1 parent b64ee90 commit 3307282

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2016 michael-simons.eu.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package ac.simons.doag2016;
17+
18+
import java.io.IOException;
19+
import java.io.PrintStream;
20+
import javax.servlet.http.HttpServletResponse;
21+
import org.springframework.boot.Banner;
22+
import org.springframework.core.env.Environment;
23+
import org.springframework.http.MediaType;
24+
import org.springframework.stereotype.Controller;
25+
import org.springframework.web.bind.annotation.GetMapping;
26+
import org.springframework.web.bind.annotation.RequestMapping;
27+
28+
/**
29+
* @author Michael J. Simons, 2016-04-15
30+
*/
31+
@Controller
32+
@RequestMapping("/api/banner")
33+
class BannerController {
34+
35+
private final Banner banner;
36+
37+
private final Environment environment;
38+
39+
BannerController(final Banner banner, final Environment environment) {
40+
this.banner = banner;
41+
this.environment = environment;
42+
}
43+
44+
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
45+
public void get(final HttpServletResponse response) throws IOException {
46+
try (PrintStream printStream = new PrintStream(response.getOutputStream())) {
47+
banner.printBanner(environment, BannerController.class, printStream);
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)