-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHelloApplication.java
More file actions
31 lines (24 loc) · 885 Bytes
/
HelloApplication.java
File metadata and controls
31 lines (24 loc) · 885 Bytes
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
package com.learnaws.hello;
import java.net.http.HttpHeaders;
import java.time.Instant;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@SpringBootApplication
@RestController
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
@GetMapping("/")
public ResponseEntity<String> welcome() {
String body = """
<h1>Welcome to Spring boot</h1>
return ResponseEntity.ok().header("Content-Type", "text/html").body(body);
}
@GetMapping("/hello")
public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello %s! It's %s", name, Instant.now());
}
}