Comments (7)
hprose 自带跨域支持,不要自己加什么 Header。
from hprose-golang.
虽然自带跨域支持但是我还是需要保留"Access-Control-Allow-Headers","Authorization"。我在service.Event定义了OnSendHeader,并且添加了这一句,但是并没有执行,问题就出现在这里。您能帮我看下如何解决这个问题?
from hprose-golang.
如果没执行说明你设置的 event 并没有实现接口 sendHeaderEvent 或 sendHeaderEvent2。
注意指针和引用不要少。
from hprose-golang.
指针我不熟悉,改过后还是没有执行,我把改过的代码给您看下,麻烦您看下哪里写的不对。谢谢了
type sendHeaderEvent2 struct{}
func (e *sendHeaderEvent2) OnSendHeader(ctx rpc.HTTPContext) {
ctx.Response.Header().Set("Access-Control-Allow-Headers","Authorization")
}
service := rpc.NewHTTPService()
service.Event = &sendHeaderEvent2{}
...
from hprose-golang.
或者您给个自定义响应头的实例让我参考好吗?我就差这一点就做好了
from hprose-golang.
type sendHeaderEvent interface {
OnSendHeader(context *HTTPContext)
}
type sendHeaderEvent2 interface {
OnSendHeader(context *HTTPContext) error
}
这两个接口的定义是这样的。
不是你熟悉不熟悉指针的问题,是你少了 *
的问题。
from hprose-golang.
完美解决,十分感谢
from hprose-golang.
Related Issues (20)
- Decoder 数据类型时异常 HOT 2
- Golang服务端发布实例方法,dotnet客户端调用的问题 HOT 2
- golang 服务端发布只能发布struct方法么,对于接口类型的发布是否支持呢 HOT 2
- 编译为windows 32位的问题(GOARCH=386)
- 请问有什么办法捕获客户端连接服务的超时事件吗 HOT 2
- constant 2147483648 overflows int
- v3 当客户端接口没有定义 error 返回值时,错误会被忽略
- v3.0的使用文档有吗?
- proxy.go method方法直接panic 导致错误 HOT 4
- 3.0 文档什么时候出? HOT 3
- proto gen hprose HOT 3
- Is there any plans to describe docs in readme? HOT 1
- 构建长连接反向调用 HOT 1
- 1.0 2.0 3.0有啥区别?
- 想问下关于数据绑定的问题 HOT 2
- 如何实现 服务端 AddFactoryMethods HOT 2
- tcp服务是单线程没有开协程吗,不能并行处理多个请求? HOT 5
- 如何支持可变的方法返回值? HOT 4
- 如何优雅Mock server? HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hprose-golang.