How to send error response in ruby if any invalid host requests web server.
As we do in java like below,
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "InValid Host");
Can any one help me out here?
Since you tagged it with Ruby on Rails I'm going to pass you the Rails method.
# in controller
render plain: 'InValid Host', status: :bad_request
# if you prefer a json response you might want to do
render json: {error: 'InValid Host'}, status: :bad_request
Check out the Rails Guide about this subject: Layouts and Rendering in Rails