当前位置:网站首页>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 .
边栏推荐
- C # switch between Chinese and English input methods
- [pit avoidance means "difficult"] actionref current. Reload() does not take effect
- Stockage des données en mémoire
- Openstack -- creating virtual machines for Nova source code analysis
- Back test of quantitative trading - tqzfuturerenkowavestrategy
- On the simple realization of Sanzi chess game and the method of judging the victory of n-zi chess
- Maui的学习之路(二)--设置
- Rust, the best choice for programmers to start a business?
- 重磅直播|BizDevOps:数字化转型浪潮下的技术破局之路
- [pit avoidance means "difficult"] the antd form dynamic form is deleted, and the first line is displayed by default
猜你喜欢

揭秘GaussDB(for Redis):全面对比Codis

Golang keyboard input statement scanln scanf code example

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

Configuring pytorch in win10 environment
![[machine learning] parameter learning and gradient descent](/img/28/bb0a66b5f0702c995ca9cd7546b678.jpg)
[machine learning] parameter learning and gradient descent

關於數據在內存中的存儲下

关于结构体,枚举,联合的一些知识

Implementation of a small book system
![leetcode:456. 132 mode [monotone stack]](/img/fa/44a5194b244f30383409ef40966453.png)
leetcode:456. 132 mode [monotone stack]

It's an artifact to launch a website in a few minutes
随机推荐
Summer Ending
关于数据在内存中的存储下
Configuring pytorch in win10 environment
Judge whether it is a mobile terminal
Shenzhen mintai'an intelligent second side_ The first offer of autumn recruitment
How to configure aliases for typescript + vite projects
触觉智能分享-RK3568在金融自助终端的应用
The starting point for learning programming.
關於數據在內存中的存儲下
Include what you use to save chaotic header files
语法'陷阱'
Component: is to switch between multiple components
sql导入这样怎么解决
Heavyweight live | bizdevops: the way to break the technology situation under the tide of digital transformation
JS prototype. slice. call(arguments); Convert pseudo array to array
C # switch between Chinese and English input methods
《MongoDB入门教程》第01篇 MongoDB简介
Django framework - caching, signaling, cross site request forgery, cross domain issues, cookie session token
On the realization of guessing numbers game
Detailed explanation of string operation functions and memory functions