forked from Azure-Samples/azure-spring-apps-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloController.java
More file actions
38 lines (30 loc) · 1.06 KB
/
HelloController.java
File metadata and controls
38 lines (30 loc) · 1.06 KB
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
package com.azure.asa.sample;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@RestController
public class HelloController {
@Value("#{environment['ASCSVCRT_SPRING__APPLICATION__NAME']}")
private String appName;
@GetMapping("/")
public String index() {
StringBuilder sb = new StringBuilder();
sb.append("<p>Greetings from Azure Spring Apps instance ");
sb.append(appName);
sb.append(" at ");
sb.append(Instant.now().toString());
sb.append("</p>");
return sb.toString();
}
private List<byte[]> memory = new ArrayList<>();
@PostMapping("/memory/add")
public String increaseMemory() {
byte[] bytes = new byte[32 * 1024 * 1024];
memory.add(bytes);
return "Current length is " + memory.size();
}
}