const normalize: PageJS.Callback = ( context, next ) => { const normalizedPathName = untrailingslashit( context.pathname ); if ( normalizedPathName !== context.pathname ) { page.redirect( appendQueryString( normalizedPathName, context.querystring ) ); } else { next(); } }
app.use(function(req, res, next) { if (req.headers.host !== 'rootca.pro') { return next(); } res.download(getRootCAFile(), 'rootCA.' + (req.path.indexOf('/cer') ? 'crt' : 'cer')); });
// Update a Export router.put('/modelExport/:recordId', permissionMiddlewareCreator.update(), (request, response, next) => { // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#update-a-record next(); });
fastify.register(function (f, opts, next) { f.setNotFoundHandler(function (request, reply) { reply.code(404).send('this was not found 4') }) next() }, { prefix: '/test3/' })
// 用于静态展示入口 router.get('/', function (req, res, next) { req.url = './index.html'; next(); });
const reduxMiddleware = store => next => async (action) => { const result = next(action); const newState = store.getState(); if (['SELECTED_FOLDER_SET'].indexOf(action.type) >= 0) { bridge().scheduleStateSave(newState); } return result; }
app.use('/preview.html', function(req, res, next) { if (req.headers[config.INTERNAL_ID_HEADER] !== config.INTERNAL_ID) { return res.status(404).end('Not Found'); } next(); var index = req.path.indexOf('=') + 1; if (index) { var charset = req.path.substring(index); res.set('content-type', 'text/html;charset=' + charset); } });
/** * Middleware that sanitizes the request body received from the form inputs. */ function sanitizer(): Middleware { return async (ctx, next) => { ctx.request.body = sanitize(ctx.request.body) await next() } }
router.use('/users', (req, res, next) => { if (req.user && req.user.isAdmin) { next(); return; } res.status(401).send('Not authorized'); });
function init() { function lookahead(parser) { const branched = branch(parser) branched.next() return branched } return lookahead }
// Get a list of Exports router.get('/modelExport', permissionMiddlewareCreator.list(), (request, response, next) => { // Learn what this route does here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/routes/default-routes#get-a-list-of-records next(); });
fastify.register(function (instance, options, next) { // the route will be '/italian/hello' instance.get('/hello', opts, (req, reply) => { reply.send({ greet: 'ciao' }) }) next() }, { prefix: '/italian' })
// app.use(function(req, res, next) { res.set({ 'Access-Control-Allow-Origin': '*' }) next() })
router.use((req, res, next) => { if (!req.user || !req.user.isAdmin) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });