中間件

什麼是中間件?

官方說法:中間件是一個用來處理django請求和響應的框架級鉤子,它是一個輕量級,低級別的插件,用於在全局範圍內改變django的輸入和輸出.每一箇中間件組件都負責一些特定的功能django

自定義中間件

中間件能夠定義五個方法:(主要是process_request和process_response)框架

process_request(self,request):spa

process_view(self, request, view_func, view_args, view_kwargs)插件

process_template_response(self,request,response)中間件

process_exception(self, request, exception)blog

process_response(self, request, response)io

 

中間件的執行流程鉤子

 

相關文章
相關標籤/搜索