I need to write an API to check if a user name already exists in a database.
I want my server (Struts Action class instance in tomcat server) to return true
/false
.
Its something like this
checkUserName?userName=john
I want to know what is the standard way to do this?
Shall I return a JSON response with just one boolean
value ... seems like a overkill.
Shall I do something like manually setting the HTTP header to 200 or 404 (for true
/false
), but that seems to violate the actual purpose of using the headers which I believe must only be used to indicate network failures etc.