1 Star 1 Fork 0

teamlint/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
kataras 提交于 2017-11-05 04:12 . Update to version 8.5.6 | Read HISTORY.md
package main
import (
"time"
"github.com/kataras/iris"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cloudwatch"
cw "github.com/iris-contrib/middleware/cloudwatch"
)
// $ go get github.com/aws/aws-sdk-go/...
// $ go run main.go
func main() {
app := iris.New()
app.Use(cw.New("us-east-1", "test").ServeHTTP)
app.Get("/", func(ctx iris.Context) {
put := cw.GetPutFunc(ctx)
put([]*cloudwatch.MetricDatum{
{
MetricName: aws.String("MyMetric"),
Dimensions: []*cloudwatch.Dimension{
{
Name: aws.String("ThingOne"),
Value: aws.String("something"),
},
{
Name: aws.String("ThingTwo"),
Value: aws.String("other"),
},
},
Timestamp: aws.Time(time.Now()),
Unit: aws.String("Count"),
Value: aws.Float64(42),
},
})
ctx.StatusCode(iris.StatusOK)
ctx.Text("success!\n")
})
// http://localhost:8080
// should give: NoCredentialProviders
// which is correct, you have to authorize your aws, we asumme that you know how to.
app.Run(iris.Addr(":8080"))
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/teamlint/iris.git
git@gitee.com:teamlint/iris.git
teamlint
iris
iris
v10.6.5

搜索帮助

0d507c66 1850385 C8b1a773 1850385