diff --git a/src/main/java/com/kri/shorturl/controller/ShortUrlController.java b/src/main/java/com/kri/shorturl/controller/ShortUrlController.java index e6cb25c..7f50b7e 100644 --- a/src/main/java/com/kri/shorturl/controller/ShortUrlController.java +++ b/src/main/java/com/kri/shorturl/controller/ShortUrlController.java @@ -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 params + ) { + URI redirectUri = shortUrlService.getRedirectUri(shortKey, params); + + return redirectUri.toString(); + } + @GetMapping("/redirect/{shortKey}") public ResponseEntity redirectShortUrl( @PathVariable String shortKey,