rest - 在 Go 中定期轮询 REST 端点

标签 rest go

我正在尝试编写一个定期轮询 PHP 应用程序公开的 REST 端点的 Go 应用程序。 Go 轮询应用程序将有效负载读入结构并进行进一步处理。我正在寻找一些开始实现的建议。

最佳答案

最简单的方法是使用代码:

ticker := time.NewTicker(time.Second * 1).C
go func() {
    for {
        select {
        case <- ticker:
            response,_ := http.Get("http://...")
            _, err := io.Copy(os.Stdout, response.Body)
            if err != nil {
                log.Fatal(err)
            }
            response.Body.Close()
        }
    }

}()


time.Sleep(time.Second * 10)

关于rest - 在 Go 中定期轮询 REST 端点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39363794/

相关文章:

web-services - 如何在Grails中创建Rest Web服务?

java - Jersey 2.22 : Where should I define the location of REST resources?

variables - Go 是否支持运算符类型变量?

go - 在 Go 中使用 channel 执行非阻塞 select 语句的首选方法是什么

go - REST HTTPS 服务器错误

json - golang Google 端点接收 JSON 以进行 Google IAB 验证并存储到 Google Datastore

java - 如何在不产生单独的 JVM 的情况下并行提交多个 Spark 应用程序?

java - SwaggerUi REST 方法 - 方法生成和使用完全相同的 mime 类型

api - 使用 Webmethods 作为客户端将附件添加到 JIRA REST API

go - 我可以得到一些帮助来推理 `concurrent prime sieve` 示例吗?