Created
July 9, 2020 12:21
-
-
Save gauravat16/90f47300d3305733d49b639f517a6a32 to your computer and use it in GitHub Desktop.
API for username validation
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
package gaurav.examples.redis.bloomfilter.controller; | |
import gaurav.examples.redis.bloomfilter.service.UserNameValidatorService; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.http.ResponseEntity; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RequestParam; | |
import org.springframework.web.bind.annotation.RestController; | |
import java.util.Optional; | |
@RestController | |
@RequestMapping("/username") | |
public class UsernameController { | |
@Autowired | |
private UserNameValidatorService userNameValidatorService; | |
@GetMapping("/exists") | |
private ResponseEntity<Boolean> doesUserNameExists(@RequestParam("name") String name) { | |
return ResponseEntity.of(Optional.of(userNameValidatorService.checkIfUserNameAvailability(name))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment