1 package de.juplo.kafka.wordcount.query;
3 import lombok.RequiredArgsConstructor;
4 import org.springframework.http.HttpStatus;
5 import org.springframework.http.ResponseEntity;
6 import org.springframework.web.bind.annotation.GetMapping;
7 import org.springframework.web.bind.annotation.PathVariable;
8 import org.springframework.web.bind.annotation.RestController;
11 import java.util.Optional;
15 @RequiredArgsConstructor
16 public class QueryController
18 private final QueryStreamProcessor processor;
20 @GetMapping("{username}")
21 ResponseEntity<Ranking> queryFor(@PathVariable String username)
23 Optional<URI> redirect = processor.getRedirect(username);
24 if (redirect.isPresent())
28 .status(HttpStatus.TEMPORARY_REDIRECT)
29 .location(redirect.get())
33 return ResponseEntity.of(processor.getRanking(username));