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
1
vote
1 answer

Exception handling middleware doesn't handle exceptions - Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware is called (ASP.NET Core WebAPI)

I created an exception handling middleware according to this example: public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseExceptionHandler("/error"); // ... } [AllowAnonymous] [ApiExplorerSettings(IgnoreApi…
Boris Makhlin
  • 240
  • 5
  • 11
1
vote
2 answers

I cant place my new middleware where I want to place it in the rack stack

I wrote a new middleware called RescueAuthTokenFromOmniauth, which rescues an exception created by either OmniAuth::Strategies::GoogleOauth2 or OmniAuth::Strategies::Facebook. Ideally, I want to place RescueAuthTokenFromOmniauth just before the…
1
vote
0 answers

Laravel middleware not working with route group, when url segments are more than 1

Here is my middleware And here are the Routes when I uncomment the dd('asd'); from hande function in locale middleware it always works on all routes like /asdasdasd or some real link, but when the url segments are more than 1, it just shows 404,…
Altro
  • 878
  • 1
  • 7
  • 23
1
vote
1 answer

Laravel - Middleware for route always 403

App\Http\Controllers\Admin\ExampleController.php public function index() { dd('index'); } app\Policies\ExamplePolicy.php public function viewAny(User $user) { return true; } app\Providers\AuthServiceProvider.php protected $policies = [ …
kodfire
  • 1,612
  • 3
  • 18
  • 57
1
vote
1 answer

UseExceptionHandler is not working with validation errors

In Asp.Net Core 5 I am using UseExceptionHandler to handle exceptions globally and it works fine unless I send an invalid object. For example I send an object with null value for the required property "Name" I receive the following error in client…
nAviD
  • 2,784
  • 1
  • 33
  • 54
1
vote
3 answers

why the underlying code gets executed in a block even after invoking next() in express?

exports.getTour = catchAsync(async (req, res, next) => { const tour = await Tour.findById(req.params.id); if (!tour) { next(new AppError('No tour found with that ID', 404)); } res.status(200).json({ status: 'success', data: { …
somesh
  • 63
  • 7
1
vote
2 answers

Trying to get property 'headers' of non-object (middleware role authentication)

i want to make two authentication roles(admin and user). every thing work fine, but for example when i am logged as user and i try to access the admin dashboard i want want redirected to the user dashboard instead cause i must not have access to it…
1
vote
1 answer

Difference between middleware and web services?

I am quite confused with these terms. As far as I understand Middleware provides the connection between devices/applications present in heterogeneous system. Web services provides the methods through which the message can be transferred using the…
MAHA JAVED
  • 13
  • 3
1
vote
3 answers

Should I Use ExceptionFilter or Middleware for Exception Handling in .NET

I am using .NET 5 and I need to global exception handling mechanism. Should I use ExceptionFilter or Middleware? Which one is the best practice for most of the ASP.NET Core applications?
Tolga Cakir
  • 725
  • 1
  • 7
  • 13
1
vote
1 answer

Node middleware to make an API request

I have a routes file that looks like this, function getEmp(req,res,next,empId) { return(req, res, next) => { getEmpById(req, res, next, employerId); } } module.exports = { router.get('/go', getEmp('my-id'), (req, res) => { …
Udders
  • 6,914
  • 24
  • 102
  • 194
1
vote
0 answers

Exception thrown but middleware context response is a 200, but response to client is 500

I've got a middleware class that logs path, time taken & response codes. public async Task InvokeAsync(HttpContext context) { var sw = Stopwatch.StartNew(); try { await _next(context); // Controller throws an exception, un caught. } …
1
vote
1 answer

Blazor middleware to run after navigating to any page

I have written a middleware class but currently only runs when I start the application, I want it to run every time the app navigates to a different page. Thanks!
Carorus
  • 535
  • 2
  • 16
1
vote
1 answer

Solution to trigger the middleware when updating of a subdocument

I use this schema of addresses and use it in several schemas. All works fine, only when I update a address const addressSchema = new mongoose.Schema({ street: String, number: String, postcode: String, city: String, comment:…
Rifton007
  • 291
  • 1
  • 5
  • 24
1
vote
1 answer

How to use go echo middleware?

I installed echo via go get -u github.com/labstack/echo/v4 Its package in go.mod like module app go 1.15 require ( github.com/labstack/echo v3.3.10+incompatible github.com/labstack/echo/v4 v4.2.0 ) In server.go, use a middleware…
oiio
  • 45
  • 1
  • 7
1
vote
2 answers

Cookie read correctly in controllers but not in middleware - Laravel

I was trying to set a cookie to define a user-preferred language. I did that by having a link that leads to a helper controller : /set-locale/{locale} public function edit_locale($locale) { $durata= 2628000; // "forever" if…
1 2 3
99
100