Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

98
Views
Ejecute middleware cuando se establece un marcador de posición específico (express.js)

Tengo una API REST y muchos puntos finales incluyen un marcador de posición específico, como este:

 app.get('/client/:client', getClient); app.put('/client/:client', updateClient); app.get('/tasks/:client', getClientTasks); // ...

Quiero ejecutar un middleware para todas las rutas, que incluyen el marcador de posición :client .

Esto es lo que se me ocurrió, pero no funciona para mí:

 // My sample middleware: function validateClient(req, res, next) { console.log('Validate client', req.params.client); next(); } // I want to bind the middleware to all endpoints with ':client' in them: app.use(':client', validateClient); // <- validateClient is not called!? // The REST endpoints. app.get('/client/:client', getClient); app.put('/client/:client', updateClient); app.get('/tasks/:client', getClientTasks);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!