From 524aff2b0c3445fbcce2e4e0a1a8c2c01c0b9f21 Mon Sep 17 00:00:00 2001 From: dennis0405 Date: Thu, 2 Jan 2025 10:55:29 +0900 Subject: [PATCH] API Test --- .../com/example/toyTeam6Airbnb/WebConfig.kt | 18 ++++++++++++++++++ .../user/controller/UserController.kt | 6 ++++++ 2 files changed, 24 insertions(+) create mode 100644 src/main/kotlin/com/example/toyTeam6Airbnb/WebConfig.kt diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/WebConfig.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/WebConfig.kt new file mode 100644 index 0000000..e6f3e2d --- /dev/null +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/WebConfig.kt @@ -0,0 +1,18 @@ +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.web.servlet.config.annotation.CorsRegistry +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer + +@Configuration +class WebConfig { + @Bean + fun corsConfigurer(): WebMvcConfigurer { + return object : WebMvcConfigurer { + override fun addCorsMappings(registry: CorsRegistry) { + registry.addMapping("/**") + .allowedOrigins("*") // 허용할 도메인 + .allowedMethods("GET", "POST", "PUT", "DELETE") + } + } + } +} diff --git a/src/main/kotlin/com/example/toyTeam6Airbnb/user/controller/UserController.kt b/src/main/kotlin/com/example/toyTeam6Airbnb/user/controller/UserController.kt index a69d9d5..10e97a9 100644 --- a/src/main/kotlin/com/example/toyTeam6Airbnb/user/controller/UserController.kt +++ b/src/main/kotlin/com/example/toyTeam6Airbnb/user/controller/UserController.kt @@ -4,6 +4,7 @@ import com.example.toyTeam6Airbnb.user.service.UserService import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -19,4 +20,9 @@ class UserController( fun ping(): ResponseEntity { return ResponseEntity.ok("pong") } + + @GetMapping("/ping") + fun getPing(): ResponseEntity { + return ResponseEntity.ok("pong") + } }