Questions tagged [middleware]

Middleware is computer software that provides services to software applications beyond those available from the operating system. It can be described as "software glue".

Middleware is a software component (or components) that sits "in the middle" between applications and the operating system. Typically, middleware will facilitate application development by providing services such as communications, file access, or thread locking that have a common Application Programming Interface (API) across multiple operating systems.

Communications Middleware is a specific kind of middleware that allows for interprocess communications (on one machine or across a network). The purpose of Communications Middleware is to simplify the designing, programming, and managing of software applications by streamlining the way these applications receive and process data. Communications Middleware simplifies writing communications software while providing sophisticated built-in features, reducing development costs.

Examples of communications middleware include:

4333 questions
8
votes
3 answers

How can I use auth0 getSession() from nextjs middleware function, or is there some other way to get user particulars via middleware

I have this code in /pages/api/_middleware.js: import { getSession } from '@auth0/nextjs-auth0' export default async function middleware(req, ev) { const session = await getSession(req) console.log(session) return…
Terry O'Neill
  • 81
  • 1
  • 3
8
votes
2 answers

Measuring view execution time in a Django middleware - good idea?

I want to check the execution time of views in my site. This can be done by decorators, but since I have dozens of views I thought of doing it in a middleware, saving the initial time in a dictionary with the request as a key (see below), but I'm…
Iftah
  • 9,512
  • 2
  • 33
  • 45
8
votes
5 answers

How to change the url using django process_request .

This is my code : class MobileMiddleware(object): def process_request(self, request): if request.path.startswith('/core/mypage/'): request.path='/core/mypage/?key=value' print request.path,'aaaa' I want to add a…
zjm1126
  • 131
  • 1
  • 1
  • 8
8
votes
0 answers

Flask session inside middleware

Is there any way to use flask session inside middleware? (flask 1.1.1) I need to access session to get "user_id" before app request. from flask import session class Middleware(object): def __init__(self, app): self.app = app def…
Hyunseo Yang
  • 151
  • 1
  • 10
8
votes
2 answers

How can I make my middleware respond with a json object if I use an API route

I'm building my first API with Laravel and I'm using JWT for authentication. I don't really understand guards all that well yet but I think I managed to guard my User class. So when I try to reach a route in my UserController it get's guarded and…
Michael
  • 355
  • 1
  • 8
  • 17
8
votes
1 answer

Route Middleware in Slim 4 doesn't stop invoking the callable in the route

I'm strugling with authorization middleware in Slim4. Here's my code: $app = AppFactory::create(); $app->add(new Authentication()); $app->group('/providers', function(RouteCollectorProxy $group){ $group->get('/',…
mk_coder
  • 83
  • 1
  • 5
8
votes
2 answers

ASP .NET Core webapi set cookie in middleware

I'm trying to set a cookie after the action is executed, struggling to get this working. I managed to see the cookie if I set it from a controller, but not from a middleware. I have played with the order of the configuration and nothing. The code…
dariogriffo
  • 4,148
  • 3
  • 17
  • 34
8
votes
3 answers

How to configure middleware in e2e test in nestjs

In real app, we write: export class AppModule implements NestModule { constructor() {} configure(consumer: MiddlewareConsumer) { consumer.apply(JwtExtractionMiddleware).forRoutes({ path: 'graphql', method: RequestMethod.ALL, …
JeffChan
  • 188
  • 2
  • 8
8
votes
4 answers

Router.use() requires a middleware function but got a undefined

I have this code in my index.js ... import userRoutes from './src/routes/userRoutes'; import invoicesRoutes from './src/routes/invoicesRoutes'; import authMiddleware from "./src/middlewares/authMiddleware"; ... const app =…
gsiradze
  • 4,583
  • 15
  • 64
  • 111
8
votes
1 answer

Custom Middleware - Too Many Redirects - Laravel

I want to create a custom middleware that only if the user is authenticated and the email is a certain email to access the /admin page. Although, when I specify my custom route and then a redirect it always says too many redirects.. Short…
Victori
  • 339
  • 2
  • 5
  • 17
8
votes
3 answers

WSGI Middleware for OAuth authentication

I have build a very small web application using Flask. Now I would like to add very basic authentication to the site (I don't need authorization). As Flask does not support auth&auth out of the box, I'd like to plug in a WSGI middleware doing this…
exhuma
  • 20,071
  • 12
  • 90
  • 123
8
votes
5 answers

Pass an array to a middleware in laravel

I got this handle in a middleware called rolMiddleware: public function handle($request, Closure $next, $roles) { //dd($request->user()); foreach ($roles as $rol) { if…
Jorge Ivan Aguirre
  • 129
  • 1
  • 1
  • 9
8
votes
3 answers

Understanding middleware and route handler in Express.js

I am trying to understand how middleware and route handlers work in Express. In Web Development with Node and Express, the author gives and example of a interesting route and middleware in action, but does not give the actual details. Can some one…
armundle
  • 1,149
  • 2
  • 15
  • 28
8
votes
1 answer

Replace IExceptionHandler in Web Api 2.2 with OWIN middleware exception handler

I have created an OWIN middleware to catch exceptions. The middleware does nothing really but wrap the next call with try catch like this try { await _next(environment) } catch(Exception exception){ // handle exception } The problem is that the…
Sul Aga
  • 6,142
  • 5
  • 25
  • 37
8
votes
3 answers

Backend solution for fetching and transforming data from various third-party APIs

We are building new feature sets for one of our financial application. We have our own SQL server database and we will be calling multiple RESTful APIs that return JSON responses. For e.g. some returns news data, some returns stocks info, some…
Priyank
  • 10,503
  • 2
  • 27
  • 25