当前位置:网站首页>Go--- route filter
Go--- route filter
2022-06-25 13:28:00 【Favorite truffle chocolate】
That is to say, for all patterns , Allow cross domain requests before routing
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowAllOrigins: true,
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Headers", "Content-Type"},
AllowCredentials: true,
}))
Parameter description :
AllowAllOrigins Allow all sources to be set to true All domain names can access the website interface , You can change this configuration to AllowOrigins:[“ Allowed access to the domain name ”]
AllowMethods : Allowed request types
AllowHeaders: Allowed header information
ExposeHeaders: Allow exposed header information
AllowCredentials: If you set , Allow sharing AuthTuffic certificate , Such as Cookie
beego.InsertFilter filter
beego.InsertFilter Filters are for certain router Provide filtering function , You can set additional operations when accessing a route . The filter execution time can be set through parameter settings .
As shown below beego.InsertFilter There are a few parameters : InsertFilter(pattern string, pos int, filter FilterFunc, params …bool)
pattern: Routing rules , Filters act as routes
pos : When the filter is executed , There are the following 5 Kind of
beego.BeforeStatic
beego.BeforeRouter Before accessing routes
beego.BeforeExec Execute after accessing the route controller Before
beego.AfterExec perform controller Then call
beego.FinishRouter Call... After the route ends
filter: Filter function , The corresponding logic of filtering according to the time specified above .
边栏推荐
- QT display ffmpeg decoded pictures
- 一篇文章讲清楚MySQL的聚簇/联合/覆盖索引、回表、索引下推
- On the realization of guessing numbers game
- 關於數據在內存中的存儲下
- Detailed explanation of string operation functions and memory functions
- ##脚本编写ssh免密功能
- Using swiper to realize seamless rotation of multiple slides
- 药物设计新福音:腾讯联合中科大、浙大开发自适应图学习方法,预测分子相互作用及分子性质
- [pit avoidance means "difficult"] to realize editable drag and drop sorting of protable
- Custom vertical table
猜你喜欢

关于数据在内存中的存储下

关于猜数字游戏的实现

Sword finger offer day 3 string (simple)

leetcode - 384. Scramble array

OpenStack学习笔记(一)

It's an artifact to launch a website in a few minutes

golang键盘输入语句scanln scanf代码示例

Rust, le meilleur choix pour un programmeur de démarrer une entreprise?

. NET in China - What's New in . NET

Pointer, it has to say that the subject
随机推荐
数据库中显示error1822,error1824
leetcode:918. Maximum sum of circular subarray [reverse thinking + maximum subarray sum]
Cesium--- figure loading
学习编程的起点。
Insight into heap and stack stored in new string() /string() in JS
OpenStack-----Nova源码分析之创建虚拟机
How to determine if a web worker has been created or closed
Rust,程序员创业的最佳选择?
How unity makes the UI intercept click events
[turn] starting from the end, analyze in detail how to fill in the college entrance examination volunteer
《MongoDB入门教程》第01篇 MongoDB简介
Prototype and prototype chain - constructor and instanceof
关于三子棋游戏的简易实现与N子棋胜利判断方法
删库跑路、“投毒”、改协议,开源有哪几大红线千万不能踩?
Restful and RPC
Detailed explanation of string operation functions and memory functions
[pit avoidance means "difficult"] to realize editable drag and drop sorting of protable
數據在內存中的存儲相關內容
Download File blob transcoding
Back test of quantitative trading - tqzfuturerenkowavestrategy