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
17
votes
3 answers

Django: How can I check the last activity time of user if user didn't log out?

django's User model has a last_login field, which is great if all the users were to log out each time they leave the site, but what if they don't? How can I track when a user who never logged out and his activity on the site?
la_f0ka
  • 1,773
  • 3
  • 23
  • 44
16
votes
3 answers

Is Django middleware thread safe?

Are Django middleware thread safe? Can I do something like this, class ThreadsafeTestMiddleware(object): def process_request(self, request): self.thread_safe_variable = some_dynamic_value_from_request def process_response(self,…
Deepan
  • 559
  • 3
  • 13
16
votes
4 answers

How to bind user object to request in a middleware

i'm writing an application in Laravel Spark 1.0 (Laravel 5.2). I wrote a custom middleware for agent (api) authentication. This is the code:
eldblz
  • 758
  • 3
  • 11
  • 24
16
votes
3 answers

Entity Framework Core 1.0 unit of work with Asp.Net Core middleware or Mvc filter

I am using EF Core 1.0 (previously known ad EF7) and ASP.NET Core 1.0 (previously known as ASP.NET 5) for a RESTful API. I'd like to have some unit of work scoped to an http request in such a way that when responding to the HTTP request either ALL…
diegosasw
  • 13,734
  • 16
  • 95
  • 159
15
votes
5 answers

FASTAPI custom middleware getting body of request inside

Been trying to get the BODY of a request using FASTAPI middleware but it seems i can only get request.headers but not the body. I am in need of the body in order to get a key that I will use to check something on the database. Think of logging or…
JC Lopez
  • 243
  • 1
  • 2
  • 12
15
votes
2 answers

Why is ASP.NET Core executing a custom middleware only once?

I have an ASP.NET Core with the following controller that accepts a POST request: [Route("api/v1/tenants/tests")] public class TestsController : Controller { [HttpPost] public IActionResult Post(string tenantId) { return…
Kzryzstof
  • 7,688
  • 10
  • 61
  • 108
15
votes
1 answer

Testing golang middleware that modifies the request

I have some middleware that adds a context with a request id to a request. func AddContextWithRequestID(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var ctx context.Context ctx =…
scuttle-jesuit
  • 648
  • 1
  • 5
  • 16
15
votes
1 answer

Order of multiple middleware in React Redux

What happen if I have multiple middleware (lets say 3 for the exemple), all catching a single action ? Do they trigger in the order defined in the store creation ? createStore(reducer,applyMiddleware(middle1, middle2, middle3)); middle1 will get…
Nevosis
  • 1,366
  • 1
  • 16
  • 27
15
votes
1 answer

How to use Middleware from an Engine in an Engine

Because of how the different gems interact in my system, I have an engine mounted onto a rails application. I recently started working on a new gem that provides some middleware functionality. Sort of like this: BaseApp \ Engine \ …
SortingHat
  • 727
  • 3
  • 15
  • 30
15
votes
2 answers

What is the common practice for targeting Foreign Servers in Oracle WebLogic Server

We’re trying to come up with something approaching a simple and straight-forward model for targeting of JMS resources in WebLogic (fat chance, I know). Queues and Topics can easily and quite intuitively be mapped to JMS servers running on WebLogic…
Andrew Phillips
  • 1,050
  • 9
  • 16
15
votes
2 answers

Django: What is the most ideal place to store project-specific middleware?

I'm aware I can "store it anywhere in my python path" and all, but what's an organized pattern I can use to store middleware classes for my project? I am appending my project root directory and project directory to the sys path through…
meder omuraliev
  • 183,342
  • 71
  • 393
  • 434
15
votes
3 answers

Slim PHP Route in Middleware

In Slim is it possible to get the current route within middleware? class Auth extends \Slim\Middleware{ public function call(){ $currentRoute = $this->app->getRoute(); // Something like this? } } I know you can call…
14
votes
3 answers

Import a Nest.js app as a simple Express middleware

I've a Nestjs app (a Rest API) that I would like to import in another node module, as a simple Express middleware (not a Nest middleware). Actually I'm still not able to make it working. // main.ts // => The main file of my Nest app, this one is…
Etienne
  • 2,257
  • 3
  • 27
  • 41
14
votes
3 answers

Cannot resolve scoped service DbContextOptions

I been searching around now for a clear cut answer on this issue, including github and still cannot see what I am missing here: Cannot resolve scoped service 'Microsoft.EntityFrameworkCore.DbContextOptions`1[PureGateway.Data.GatewayContext]' from…
14
votes
3 answers

Rack middleware "trapping" stack trace

I have a piece of Rack middleware that loads a tenant, via subdomain, and applies some default settings. The middleware, while not pretty, does it's job fine enough. However, when an exception is thrown within the app the middleware "traps" the full…
bennick
  • 1,879
  • 15
  • 21