Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different methods to one path #1

Closed
yuraantonov11 opened this issue Jan 22, 2018 · 1 comment
Closed

different methods to one path #1

yuraantonov11 opened this issue Jan 22, 2018 · 1 comment

Comments

@yuraantonov11
Copy link

how to create request with different methods or request with id to one path?

@supermamon
Copy link
Owner

Hope this helps.

// /routes/profile/index.js

const config    = require('../../config')

module.exports = (server) => {
    var PATH = config.basePath('/profile/:id')

    // setup the method handlers here.  
    server.get({ path: PATH, version: '1.0.0' }, require('./v1'))
    server.post({ path: PATH, version: '1.0.0' }, require('./v1'))
    // the handlers does not have to be 1 file. for instance, you can use v1-get.js for the get method and v1-post.js for th post method.

}
// /routes/profile/v1.js

module.exports = (req, res, next) => {
    res.send(`Welcome ${req.params.id}!`)
    return next()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants