- 浏览: 2552644 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
SuperPlan(14)Winner Seller Server - JSON Cross Domain
16. JSON cross domain
I will rock and roll in JSON REST and JSON client now. JSONP is not what I want.
It is complex than I thought. Actually, I make the JSON basic auth working with JSONP basic auth. JSONP is for the navigate bars, JSON is working for the products right now.
16.1 Server Side
I need to extend the HttpHeader to enable the cross domain access. The documents in spray are not in detail, it take time to understand and read the source scala codes in spray.
package object CrossDomainHeaders {
case class Origin(origin: String) extends HttpHeader {
def name = "Origin"
def lowercaseName = "origin"
def value = origin
}
case class `Access-Control-Allow-Origin`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Origin"
def lowercaseName = "access-control-allow-origin"
def value = origin
}
case class `Access-Control-Allow-Headers`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Headers"
def lowercaseName = "access-control-allow-headers"
def value = origin
}
case class `Access-Control-Allow-Methods`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Methods"
def lowercaseName = "access-control-allow-methods"
def value = origin
}
case class `Access-Control-Allow-Credentials`(allowed: Boolean) extends HttpHeader {
def name = "Access-Control-Allow-Credentials"
def lowercaseName = "access-control-allow-credentials"
def value = if(allowed) "true" else "false"
}
}
In my router, I need to consider to get the request header, find out the origin URL and match my white list of the domain names.
…snip...
implicit val productFormatter = ProductJsonProtocol.ProductJsonFormat
headerValueByName("Origin") { originHeader =>
respondWithHeaders(`Access-Control-Allow-Origin`(originHeader),`Access-Control-Allow-Credentials`(true)) {
authenticate(BasicAuth(new BrandUserPassAuthenticator(dao), "Realm")) { user =>
…snip…
Right now, it will access all the domain names, because it just say originHeader, I will rewrite it to match a white list.
Here is the way to read the white list in configuration file.
server {
address = "0.0.0.0"
port = 9001
crossdomain.eanble = true
crossdomain.list = [ "http://localhost:9000", "http://localhost:9001" ]
}
val lists = config.getStringList("server.crossdomain.list")
16.2 Client Side
There is nothing special on the client, because we send the credential to server via jsonp.
//json
if(config.productsProvider == 'json'){
options.dataType = "json";
options.crossDomain = true;
options.xhrFields = { withCredentials: true };
//options.beforeSend = function (xhr) {
// xhr.setRequestHeader('Authorization', 'Basic Y3VzdG9tZXI6Y3VzdG9tZXI=');
//};
var url_str = 'http://' + config.remoteServerURL + ':' + config.remoteServerPort
url_str = url_str + '/' + config.apiVersion + '/' + config.brandName + '/' + 'products';
options.url = url_str;
}
17. Jasmine
come sonn...
18. Integration(Backbone + Require + Jasmine + Phantom + Grunt + Bootstrap)
come soon…
References:
superPlan 13
http://sillycat.iteye.com/blog/1885313
integration
http://hdnrnzk.me/2013/01/10/backbone-requirejs-jasmine-phantomjs-and-grunt/
https://github.com/ghiden/backbone-requirejs-jasmine-phantomjs-grunt-setup
superplan(11) phantom
http://sillycat.iteye.com/blog/1874971
16. JSON cross domain
I will rock and roll in JSON REST and JSON client now. JSONP is not what I want.
It is complex than I thought. Actually, I make the JSON basic auth working with JSONP basic auth. JSONP is for the navigate bars, JSON is working for the products right now.
16.1 Server Side
I need to extend the HttpHeader to enable the cross domain access. The documents in spray are not in detail, it take time to understand and read the source scala codes in spray.
package object CrossDomainHeaders {
case class Origin(origin: String) extends HttpHeader {
def name = "Origin"
def lowercaseName = "origin"
def value = origin
}
case class `Access-Control-Allow-Origin`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Origin"
def lowercaseName = "access-control-allow-origin"
def value = origin
}
case class `Access-Control-Allow-Headers`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Headers"
def lowercaseName = "access-control-allow-headers"
def value = origin
}
case class `Access-Control-Allow-Methods`(origin: String) extends HttpHeader {
def name = "Access-Control-Allow-Methods"
def lowercaseName = "access-control-allow-methods"
def value = origin
}
case class `Access-Control-Allow-Credentials`(allowed: Boolean) extends HttpHeader {
def name = "Access-Control-Allow-Credentials"
def lowercaseName = "access-control-allow-credentials"
def value = if(allowed) "true" else "false"
}
}
In my router, I need to consider to get the request header, find out the origin URL and match my white list of the domain names.
…snip...
implicit val productFormatter = ProductJsonProtocol.ProductJsonFormat
headerValueByName("Origin") { originHeader =>
respondWithHeaders(`Access-Control-Allow-Origin`(originHeader),`Access-Control-Allow-Credentials`(true)) {
authenticate(BasicAuth(new BrandUserPassAuthenticator(dao), "Realm")) { user =>
…snip…
Right now, it will access all the domain names, because it just say originHeader, I will rewrite it to match a white list.
Here is the way to read the white list in configuration file.
server {
address = "0.0.0.0"
port = 9001
crossdomain.eanble = true
crossdomain.list = [ "http://localhost:9000", "http://localhost:9001" ]
}
val lists = config.getStringList("server.crossdomain.list")
16.2 Client Side
There is nothing special on the client, because we send the credential to server via jsonp.
//json
if(config.productsProvider == 'json'){
options.dataType = "json";
options.crossDomain = true;
options.xhrFields = { withCredentials: true };
//options.beforeSend = function (xhr) {
// xhr.setRequestHeader('Authorization', 'Basic Y3VzdG9tZXI6Y3VzdG9tZXI=');
//};
var url_str = 'http://' + config.remoteServerURL + ':' + config.remoteServerPort
url_str = url_str + '/' + config.apiVersion + '/' + config.brandName + '/' + 'products';
options.url = url_str;
}
17. Jasmine
come sonn...
18. Integration(Backbone + Require + Jasmine + Phantom + Grunt + Bootstrap)
come soon…
References:
superPlan 13
http://sillycat.iteye.com/blog/1885313
integration
http://hdnrnzk.me/2013/01/10/backbone-requirejs-jasmine-phantomjs-and-grunt/
https://github.com/ghiden/backbone-requirejs-jasmine-phantomjs-grunt-setup
superplan(11) phantom
http://sillycat.iteye.com/blog/1874971
发表评论
-
Stop Update Here
2020-04-28 09:00 316I will stop update here, and mo ... -
NodeJS12 and Zlib
2020-04-01 07:44 476NodeJS12 and Zlib It works as ... -
Docker Swarm 2020(2)Docker Swarm and Portainer
2020-03-31 23:18 369Docker Swarm 2020(2)Docker Swar ... -
Docker Swarm 2020(1)Simply Install and Use Swarm
2020-03-31 07:58 370Docker Swarm 2020(1)Simply Inst ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 337Traefik 2020(1)Introduction and ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 431Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 436Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 374Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 456VPN Server 2020(2)Docker on Cen ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 385Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 479NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 424Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 337Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 248GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 452GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 328GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 314Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 319Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 294Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 312Serverless with NodeJS and Tenc ...
相关推荐
作为一种广泛存在于各个领域的竞争现象,关于赢者通吃(winner-take-all)的大部分研究太复杂以至于难以很好地理解该现象。为了用简单的方式解释winner-take-all现象,提出了一个改进的winner-take-all模型,由离散...
SOM网络即自组织特征映射网络,采用竞争学习规则——Winner-Take-All 。网络的输出神经元之间相互竞争以求被激活,结果在每一时刻只有一个输出神经元被激活。这个被激活的神经元称为竞争获胜神经元,而其它神经元的...
《MetaTrader 5脚本:AFL_Winner_Signal深入解析》 在金融交易领域,自动化交易系统(Automated Trading System)已经变得越来越普遍,其中MetaTrader 5(MT5)是一个广泛使用的交易平台,它提供了丰富的功能和工具...
为了解决上述问题,本研究提出了结合Winner-Take-All(WTA)竞争模型和改进的人工势场(Artificial Potential Field,简称APF)路径规划方法的控制策略。WTA竞争模型是一种有效的多机器人竞争问题解决方案,它模拟了...
ZS-Young-Data-scientist-2018-Winner-Solution-rank-3:ZS年轻数据科学家挑战赛2018
在IT行业中,"Winner-gets-all"这个标题可能暗示了一个竞争激烈的环境,特别是在软件开发或者数据分析的场景下,其中胜者通常能获取大部分资源或市场份额。在这个特定的案例中,结合"世界高尔夫协会工作流程"的描述...
SCM WINNER II Channel Models, D1.1.2 V1.2, IST-4-027756 WINNER II Deliverable
默认情况下,winner-mode 包含在 emacs 中,因为版本 20 但它没有启用。 这是一个制作支持微功能的包的实验。 我有一段时间的想法,我终于要测试了。 安装 这个包裹是果酱。 从果酱安装它 package-install winner-...
冠军得主,鸡肉晚餐! :rooster: 输入列表并旋转方向盘,即可每次获得随机赢家。 :crystal_ball: 目录 特征 输入名称或对象列表。 编辑并删除您的列表。 始终使用localStorage访问您最近创建的列表。...
ToneWinner天逸设备说明书
WINNER II信道模型的建模与仿真 绍WINNER II信道模型所支持的场景,信道建模方法及信道参数和信道系数产生.
在给定的"winner-filter.zip"压缩包文件中,包含了一个名为"维纳滤波器仿真.m"的MATLAB代码文件,这显然是一个用于仿真和分析维纳滤波器性能的程序。MATLAB是一种广泛应用于科学计算、数据分析和工程领域的编程环境...
ToneWinner天逸设备说明书
在电子商务领域,组合拍卖(Combinatorial Auction)是一种复杂而有趣的拍卖形式,它允许投标人提交对多个物品的联合出价,而非仅仅对单个物品出价。这种拍卖机制旨在优化资源配置,提高拍卖效率,同时也增加了投标...
ToneWinner天逸EF-100正是为了满足这一需求而精心设计打造的一款音响设备,它以卓越的音质和丰富的功能配置,给用户带来沉浸式的听觉盛宴。为了确保用户能充分且安全地享受天逸EF-100带来的美妙体验,本篇文章将对这...
winner2信道模型仿真了3D信道模型,里面涉及好多应用场景。可以与现实生活中的场景相匹配
《AFL_Winner - MetaTrader 5脚本.zip:基于趋势反转的交易策略解析》 在金融交易领域,有效的指标工具对于投资者来说至关重要。本文将深入解析名为"AFL_Winner"的MetaTrader 5脚本,它是一款专为MT5交易平台设计的...
Parse FB comments/reactions/shares and import them into Luckydog Winner Generator 如果您需要整合留言、按赞、分享当作抽奖条件,或使用luckydog提供的抽奖联络表单,您必须使用chrome扩充程式开奖机,它会要求...
Parse FB comments/reactions/shares and import them into Luckydog Winner Generator 如果您需要整合留言、按赞、分享当作抽奖条件,或使用luckydog提供的抽奖联络表单,您必须使用chrome扩充程式开奖机,它会要求...
WINNER-II场景下的信道仿真模型,可用于分析各个场景下的信道参数