-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathNameController.java
More file actions
28 lines (22 loc) · 805 Bytes
/
NameController.java
File metadata and controls
28 lines (22 loc) · 805 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
package com.example.midterm;
import dto.Name; // Import your Name DTO
import service.NameService; // Import your NameService
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
public class NameController {
@Autowired
private NameService nameService;
// Serve the main HTML page
@GetMapping("/")
public String index() {
return "index"; // This will serve the index.html file from static resources
}
// Process the name input from the frontend
@PostMapping("/process")
public Name processName(@RequestBody Map<String, String> request) throws Exception {
String nameInput = request.get("name");
return nameService.process(nameInput);
}
}