   message = ''
 
   robot.router.get "#{path}", (req, res) ->
+    check_request req
+
     query   = querystring.parse(req._parsedUrl.query)
     room    = query.room
     message = query.message
-    console.log "query: %j", query
+    if debug
+      console.log "query: %j", query
+
     send_message(res, room, message, query)
 
   robot.router.post "#{path}", (req, res) ->
+    check_request req
+
     query   = querystring.parse(req._parsedUrl.query)
     room    = query.room or ''
     message = req.body.message
     room    = req.body.room unless room
+
     send_message(res, room, message, req.body)
 

    res.end 'Error: There is no room to say.'

  # console.log "query: %j", query
  options = {}
  if query.color?
    options['color'] = query.color
  if query.icon_emoji?
    options['icon_emoji'] = query.icon_emoji
  if query.icon_url?
    options['icon_url'] = query.icon_url

  if ircType == "slack"
    # @sm.send ["#{room}"], "", @sm.slack_attachments("", msg)
    @sm.send ["#{room}"], msg, query
  else
    @sm.send ["#{room}"], msg
  res.writeHead 200, {'Content-Type': 'text/plain'}
  res.end 'OK'

module.exports = (robot) ->


querystring = require 'querystring'
SendMessage = require './send_message'
prefix      = "[http_irc]"
type        = process.env.HUBOT_IRC_TYPE
debug       = process.env.HUBOT_HTTP_IRC_DEBUG
api_key     = process.env.HUBOT_HTTP_IRC_API_KEY
allow       = process.env.HUBOT_HTTP_IRC_ALLOW
deny        = process.env.HUBOT_HTTP_IRC_DENY
allow_flag  = false

send_message = (res, room, msg, query) ->
  # console.log "room: #{room}"
