-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: RootController 분리 * refactor: WebController -> AppController 이름 변경 * fix: 클래스 가시성 조절 * feat: /api/health 컨트롤러 추가
- Loading branch information
1 parent
65e9bfb
commit daa4f13
Showing
5 changed files
with
48 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/main/java/io/github/daengdaenglee/mangurl/inboundadapter/app/form/ShortenUrlForm.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package io.github.daengdaenglee.mangurl.inboundadapter.app.form; | ||
|
||
public record ShortenUrlForm(String originalUrl) { | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/github/daengdaenglee/mangurl/inboundadapter/root/RootController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.daengdaenglee.mangurl.inboundadapter.root; | ||
|
||
import io.github.daengdaenglee.mangurl.application.url.inboundport.EncodeUrlService; | ||
import io.github.daengdaenglee.mangurl.application.url.inboundport.RestoreUrlService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.server.ResponseStatusException; | ||
|
||
@Slf4j | ||
@RequiredArgsConstructor | ||
@Controller | ||
class RootController { | ||
private final RestoreUrlService restoreUrlService; | ||
private final EncodeUrlService encodeUrlService; | ||
|
||
@RequestMapping("/{shortUrlCode}") | ||
String redirect(@PathVariable String shortUrlCode) { | ||
return this.restoreUrlService.restoreUrl(shortUrlCode) | ||
.map(this.encodeUrlService::encode) | ||
.map(url -> "redirect:" + url) | ||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND)); | ||
} | ||
|
||
@RequestMapping | ||
String home() { | ||
return "redirect:/app"; | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/io/github/daengdaenglee/mangurl/inboundadapter/web/form/ShortenUrlForm.java
This file was deleted.
Oops, something went wrong.