中间件代码实现
<?php
/**
* User: Jobs Lin
* Date: 2019/12/14
* Time: 19:52
*/
interface Milldeware {
    public static function handle(Closure $next);
}


class VerfiyCsrfToekn implements Milldeware {


    public static function handle(Closure $next)
    {
        echo '验证csrf Token
';
        $next();
    }
}


class VerfiyAuth implements Milldeware {


    public static function handle(Closure $next)
    {
        echo '验证是否登录
';
        $next();
    }
}


class SetCookie implements Milldeware {
    public static function handle(Closure $next)
    {
        $next();
        echo '设置cookie信息!';
    }
}


$handle = function() {
    echo '当前要执行的程序!';
};


$pipe_arr = [
    'VerfiyCsrfToekn',
    'VerfiyAuth',
    'SetCookie',
];


$callback = array_reduce($pipe_arr,function($stack,$pipe) {
    return function() use($stack,$pipe){
        return $pipe::handle($stack);
    };
},$handle);


call_user_func($callback);
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇