当一个类添加了如下注解的话,装配类的时候,其setter方法(注意,确切说不是属性)就会参考application.properties 文件总对应的配置的,而且,在IDE中添加这种配置时,IDE也会给出提示
ngx.resp.get_headers()
syntax: headers = ngx.resp.get_headers(max_headers?, raw?)
context: set_by_lua*, rewrite_by_lua*, access_by_lua*, content_by_lua*, header_filter_by_lua*, body_filter_by_lua*, log_by_lua*, balancer_by_lua*
Returns a Lua table holding all the current response headers for the current request.
1 2 3 4 |
<span class="pl-k">local</span> h <span class="pl-k">=</span> ngx.<span class="pl-smi">resp</span>.<span class="pl-c1">get_headers</span>() <span class="pl-k">for</span> k, v <span class="pl-k">in</span> <span class="pl-c1">pairs</span>(h) <span class="pl-k">do</span> <span class="pl-c1">...</span> <span class="pl-k">end</span> |
This function has the same signature as ngx.req.get_headers except getting response headers instead of request headers.
参考: https://github.com/openresty/lua-nginx-module#ngxrespget_headers
注意: 字段名都会转换成小写
1 2 3 4 5 6 |
expires:Thu, 19 Nov 1981 08:52:00 GMT content-type:text/html; charset=utf-8 connection:keep-alive cache-control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0 pragma:no-cache content-encoding:gzip |
如何从零开始写一个 Chrome 扩展? – 知乎
Chrome扩展:拦截网页JS并替换
saltstack pillar 维护
默认情况下,pillar信息是维护在文件中的,虽然方便,如果要自动化的话,就不太方便,如果能存到数据库会方便维护一些。
相关salt模块:https://docs.saltstack.com/en/latest/ref/pillar/all/index.html
将pillar信息存入mysql:
https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.mysql.html
其实,还有现成的模块可以将pillar信息存储mongodb、ldap、redis等
https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.pillar_ldap.html
https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.redismod.html
https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.postgres.html
https://docs.saltstack.com/en/latest/ref/pillar/all/salt.pillar.git_pillar.html
持续构建之maven + Jenkins + Nexus
一般来讲,maven deploy时要部署到Nexus,需要在pom.xml 中添加如下类似的东东:
1 2 3 4 5 6 7 8 9 10 11 12 |
<distributionManagement> <repository> <id>releases</id> <name>Nexus Release Repository</name> <url>http://nexus.phpor.net/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots</id> <name>Nexus Snapshot Repository</name> <url>http://nexus.phpor.net/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> |
如此的话,该pom.xml 就不便于分享,还有人喜欢deploy到自己的Nexus呢;
其实,还可以在mvn deploy 时通过参数的方式来指定,如:
1 |
mvn deploy -D altDeploymentRepository=snapshots::default::http://nexus.phpor.net/nexus/content/repositories/snapshots/ |
这样的话,不管snapshot还是release都会deploy到相同位置; 正确的姿势为分别设置snapshot和release的位置,如下:
1 2 |
mvn deploy -D altSnapshotDeploymentRepository=snapshots::default::http://nexus.phpor.net/nexus/content/repositories/snapshots/ -D altReleaseDeploymentRepository=releases::default::http://nexus.phpor.net/nexus/content/repositories/releases/ |
参考:https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html
docker swarm 模式下证书过期后daemon无法启动
报错信息:
1 |
Error creating cluster component: error while loading TLS Certificate |
相关文章: https://github.com/moby/moby/issues/24132
解决办法: 把 Docker Root Dir (通过docker info查看)下的swarm目录删掉就好了
xfire 代理设置
xfire 可以通过如下方式设置代理:
1 2 |
client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_HOST, httpProxyHost); client.setProperty(CommonsHttpMessageSender.HTTP_PROXY_PORT, httpProxyPort); |
需要注意的是,该代理配置并不作用于下载wsdl
java问题
java 用很多内存,占用全部的cpu:
1 2 3 4 5 6 7 8 9 |
{Heap before GC invocations=3629 (full 101): PSYoungGen total 699392K, used 350208K [0x0000000780000000, 0x00000007c0000000, 0x00000007c0000000) eden space 350208K, 100% used [0x0000000780000000,0x0000000795600000,0x0000000795600000) from space 349184K, 0% used [0x00000007aab00000,0x00000007aab00000,0x00000007c0000000) to space 349184K, 0% used [0x0000000795600000,0x0000000795600000,0x00000007aab00000) ParOldGen total 2097152K, used 2097081K [0x0000000700000000, 0x0000000780000000, 0x0000000780000000) object space 2097152K, 99% used [0x0000000700000000,0x000000077ffee728,0x0000000780000000) Metaspace used 69136K, capacity 72006K, committed 73560K, reserved 1114112K class space used 7517K, capacity 8088K, committed 8320K, reserved 1048576K |
golang 中的只读变量
示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package proxy import ( "net" ) type direct struct{} // Direct is a direct proxy: one that makes network connections directly. var Direct = direct{} func (direct) Dial(network, addr string) (net.Conn, error) { return net.Dial(network, addr) } |
上面是 golang.org/x/net/proxy/direct.go 里面的代码
- 我们显然是可以在proxy包外访问到Direct变量的
- 我们显然是无法在proxy包外new 一个 direct 结构变量的
- 由于2,而且我们无法改变Direct的变量类型,所以,我们做不到给Direct进行重新赋值