260612_06_ENH: redirect 외에도 url을 받아오는 내용 추가
This commit is contained in:
@@ -6,7 +6,6 @@ import com.kri.shorturl.dto.ShortUrlCreateRequestDto;
|
||||
import com.kri.shorturl.service.ShortUrlService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import java.net.URI;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/short-url")
|
||||
@@ -29,6 +27,16 @@ public class ShortUrlController {
|
||||
|
||||
private final ShortUrlService shortUrlService;
|
||||
|
||||
@GetMapping("/{shortKey}")
|
||||
public String getRedirectUrl(
|
||||
@PathVariable String shortKey,
|
||||
@RequestParam MultiValueMap<String, String> params
|
||||
) {
|
||||
URI redirectUri = shortUrlService.getRedirectUri(shortKey, params);
|
||||
|
||||
return redirectUri.toString();
|
||||
}
|
||||
|
||||
@GetMapping("/redirect/{shortKey}")
|
||||
public ResponseEntity<Void> redirectShortUrl(
|
||||
@PathVariable String shortKey,
|
||||
|
||||
Reference in New Issue
Block a user