All language subtitles for 008 Middleware - Running Code Before & After Request_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranรฎ)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

In this lecture, I will introduce the concept of middleware.

So in simplest terms, the middleware is the code that runs before and after the controller, an example

job of before middleware is to limit access to only the authenticated users.

Now, the example job of after middleware is to add some headers to the response.

You can create your own middleware, though, it's also heavily used internally by Laravel to supply

typical functionality, middleware is a piece B class and it has to have at least one method called

handle.

It does not have to extend any base, class or interface.

These are two minimal examples of an before and after model where the perform action command is, where

you'd put some extra logic if you really want to understand how to make your own middleware.

It's a good idea to look at existing middleware provided with Laravel.

There are three levels of applying middleware first, global essential middleware is applied on all

routes always.

Secondly, some is applied only in Web and API routes, all of above is configurable in the kernel file,

which will take a look at in a second third level, Eastern were applied per route groups per controller

class.

You will learn about control classes in a bid or per individual route.

Let's take a look at the colonel file, which can be found inside the app HTP folder.

The middleware field defines their globally applied middleware.

The middle where groups feel that defined the Web and API roots specific middleware.

One of the root object methods is middleware.

That way, you can apply to a group of roots or a specific route now to make it a little bit easier.

You don't have to use a full class name like you've seen in the colonel file.

In this colonel be filed, there is another field called Route Middleware, and it defines a thing called

analysis.

Now using this Elias's, you can easily apply middleware using the middleware method and passing those.

Elias's using a comma separated string.

For example, if I would use that Alpha Middleware on this specific route from now on, it would require

the user to be authenticated to visit this route.

Now, the middleware also can accept parameters and we will use it later when we cover the user authorization.

Finally, let's verify if the S middleware was properly applied on this route.

So currently the route looks like this.

After refreshing this page, I should see some kind of error because we have no concept of authentication

in our application yet.

And indeed, after refreshing, you see an error.

There is nothing to worry about when you will learn about authentication in Laravel, this error would

just simply go away.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.