getting the request object in connect router

Hi i have a connect middleware which uses the connect router to handle request for methods like get,post etc.I want to throw error if a person chooses methods other than these two.I do not have scope for the request object inside the router function.Below is my code

var connectDomain = require('connect-domain'),
connectRoute = require('connect-route'),
connect = require('connect'),
app = connect();
app.use(connectDomain()) // For error handling   
.use(connect.query())// To use automatic query
.use(connectRoute(function (router) {
    // To Handle Get request
    router.get('/aaa', function (req, res, next) {         
        console.log ("Got Trigger request to GET");
    })
    // To Handle POST request
    router.post('/aaa', function (req, res, next) {

        console.log ("Got Trigger request to POST);


    })
}))

I have scope for the request object inside router.get and router.post.I need to check for the req.method before these and throw an error.I am unable to proceed further.Any help will be much helpful

You could use a middleware for that:

app.use(connectDomain())   
.use(connect.query())
.use(function(req, res, next) {
  if (req.method !== 'GET' && req.method !== 'POST') {
    res.writeHead(405);
    res.end('You are not allowed to use this method!');
  } else {
    next();
  }
})
.use(connectRoute(function (router) {
   ...
}));