go-zero icon indicating copy to clipboard operation
go-zero copied to clipboard

defines the method to customize http server

Open sniperwzq opened this issue 1 year ago • 2 comments

单体服务部署时需要支持热更新,一些开源方案如overseer等需要使用http Serve,gozero的internal.StartHttp是支持StartOption的,但是Server Start不支持设置,发起pr支持start时自定义StartOption

sniperwzq avatar Jul 19 '22 06:07 sniperwzq

It doesn't work, because Start(...StartOption) doesn't meet the Service interface.

So the server cannot be added into a ServiceGroup.

I think you can use RunOption to achieve that.

kevwan avatar Jul 23 '22 04:07 kevwan

It doesn't work, because Start(...StartOption) doesn't meet the Service interface.

So the server cannot be added into a ServiceGroup.

I think you can use RunOption to achieve that.

不能用RunOption, server.Start时才创建了http.Server, rest.RunOption在MustNewServer的时候就调用了; 需求是让api的http server能接受另一个 net.Listener, 类似 svr.ListenAndServe要Serve一下 image

sniperwzq avatar Jul 25 '22 02:07 sniperwzq

Would you please add unit tests?

kevwan avatar Jan 07 '23 09:01 kevwan

Codecov Report

Merging #2171 (4e1c957) into master (211b949) will decrease coverage by 0.07%. The diff coverage is 26.66%.

Impacted Files Coverage Δ
rest/engine.go 92.07% <11.11%> (-1.24%) :arrow_down:
rest/server.go 94.85% <50.00%> (-1.64%) :arrow_down:

... and 3 files with indirect coverage changes

codecov-commenter avatar Jan 07 '23 09:01 codecov-commenter