Process request for route spec.

    Either a new one is posted or the current one is to be retrieved.

def handle_route_spec_request():
    """
    Process request for route spec.

    Either a new one is posted or the current one is to be retrieved.

    """
    try:
        if bottle.request.method == 'GET':
            # Just return what we currenty have cached as the route spec
            data = CURRENT_STATE.route_spec
            if not data:
                bottle.response.status = 404
                msg = "Route spec not found!"
            else:
                bottle.response.status = 200
                msg = json.dumps(data)
        else:
            # A new route spec is posted
            raw_data = bottle.request.body.read()
            new_route_spec = json.loads(raw_data)
            logging.info("New route spec posted")
            common.parse_route_spec_config(new_route_spec)
            _Q_ROUTE_SPEC.put(new_route_spec)
            bottle.response.status = 200
            msg = "Ok"

    except ValueError as e:
        logging.error("Config ignored: %s" % str(e))
        bottle.response.status = 400
        msg = "Config ignored: %s" % str(e)

    except Exception as e:
        logging.error("Exception while processing HTTP request: %s" % str(e))
        bottle.response.status = 500
        msg = "Internal server error"

    bottle.response.content_type = 'application/json'

    return msg