Skip to content

Commit

Permalink
Merge 093d991 into 56a9467
Browse files Browse the repository at this point in the history
  • Loading branch information
Krystofee committed Oct 15, 2019
2 parents 56a9467 + 093d991 commit c454757
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion docs/Middleware.md
Expand Up @@ -38,6 +38,8 @@ Fastify middleware also do not expose the `send` method or other methods specifi
#### Restrict middleware execution to a certain path(s)
If you need to run a middleware only under certain path(s), just pass the path as first parameter to `use` and you are done!

The middleware syntax is different from the fastify route syntax. We use [middie](https://github.com/fastify/middie) to support express.js.

*Note that this does not support routes with parameters, (eg: `/user/:id/comments`) and wildcards are not supported in multiple paths.*

```js
Expand All @@ -48,7 +50,7 @@ const serveStatic = require('serve-static')
fastify.use('/css', serveStatic(path.join(__dirname, '/assets')))

// Wildcard path
fastify.use('/css/*', serveStatic(path.join(__dirname, '/assets')))
fastify.use('/css/(.*)', serveStatic(path.join(__dirname, '/assets')))

// Multiple paths
fastify.use(['/css', '/js'], serveStatic(path.join(__dirname, '/assets')))
Expand Down

0 comments on commit c454757

Please sign in to comment.