Skip to content

Instantly share code, notes, and snippets.

@gauravat16
Created July 9, 2020 12:21
Show Gist options
  • Save gauravat16/90f47300d3305733d49b639f517a6a32 to your computer and use it in GitHub Desktop.
Save gauravat16/90f47300d3305733d49b639f517a6a32 to your computer and use it in GitHub Desktop.
API for username validation
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