 		return res.render 'error', { err }
 	else
 		res.send StringifySafe err, null, 2
-
-notFoundHandler = (req, res) ->
-	if Accepts(req).type('text/html')
-		return res.render '404', {reqJSON: StringifySafe(req, null, 2)}
-	else
-		res.end()
-
-
 
 accessLogger = Morgan 'combined', stream: Fs.createWriteStream(__dirname + '/../data/logs/access.log', {flags: 'a'})
 accessLoggerDev = Morgan 'dev'


log = require('./log')(module)

errorHandler = (err, req, res, next) ->
	if typeof err is 'string'
		err = {'message': err}

		# Log access
		@app.use accessLogger
		@app.use accessLoggerDev
		controlers = [
			'header'
			'restful'
			'schemo'
			'upload'
			'execute'
			'monitor'
			'ldf'
			'swagger'
			'json-import'
			'syntax-highlight'
			'play'
		]
		Async.eachSeries controlers, (controller, done) =>
			log.info "Setting up route #{controller}"
			done null, require("./routes/#{controller}")(@app)
		, (err, next) =>
			# root route
			@app.get '/', (req, res, next) ->
				res.status 302
				res.header 'Location', 'http://infolis.github.io'
				res.end()
			# Error handler
			@app.use errorHandler
			# 404 handler
			@app.use notFoundHandler

	startServer : () ->
		log.info "Setting up routes"
