Skip to content

Commit

Permalink
add go mod, add rest api
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoliang committed Aug 3, 2020
1 parent 882ccff commit 2062629
Show file tree
Hide file tree
Showing 7 changed files with 346 additions and 12 deletions.
2 changes: 1 addition & 1 deletion example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FROM golang:1.12.10 as builder

ADD . /example/
WORKDIR /example/
ENV GOPROXY=https://goproxy.io
ENV GOPROXY=https://goproxy.cn
RUN go build -a github.com/go-chassis/go-chassis-cloud/example


Expand Down
7 changes: 0 additions & 7 deletions example/conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
---
cse:
service:
registry:
address: https://cse.cn-north-1.myhuaweicloud.com
protocols:
rest:
listenAddress: "0.0.0.0:4000"
handler:
chain:
Provider:
default: tracing-provider,bizkeeper-provider
servicecomb:
engine:
name: default
2 changes: 1 addition & 1 deletion example/conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
#微服务的私有属性
service_description:
name: noService
name: HelloCloudService
# status: TESTING
6 changes: 3 additions & 3 deletions example/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/go-chassis/go-chassis-cloud/example
go 1.13

require (
github.com/go-chassis/go-chassis v1.8.2-0.20200107083309-71c655a474e3
github.com/go-chassis/go-chassis-cloud v0.1.1-0.20200110063145-843d545dc590
github.com/go-chassis/go-archaius v1.2.1
github.com/go-chassis/go-chassis v1.8.3
github.com/go-chassis/go-chassis-cloud v0.2.0
github.com/huaweicse/auth v1.1.2 // indirect
go.uber.org/atomic v1.5.0 // indirect
)
19 changes: 19 additions & 0 deletions example/main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package main

import (
"github.com/go-chassis/go-archaius"
"github.com/go-chassis/go-chassis"
"github.com/go-chassis/go-chassis/server/restful"
"net/http"

_ "github.com/go-chassis/go-chassis-cloud/provider/huawei/engine"
)

func main() {
chassis.RegisterSchema("rest", &HelloResource{})
err := chassis.Init()
if err != nil {
panic(err)
Expand All @@ -16,3 +20,18 @@ func main() {
panic(err)
}
}

type HelloResource struct {
}

func (r *HelloResource) Welcome(b *restful.Context) {
b.Write([]byte("hello: " + archaius.GetString("user", "")))

}

func (r *HelloResource) URLPatterns() []restful.Route {
return []restful.Route{
{Method: http.MethodPost, Path: "/welcome", ResourceFunc: r.Welcome,
Returns: []*restful.Returns{{Code: 200}}},
}
}
12 changes: 12 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module github.com/go-chassis/go-chassis-cloud

go 1.13

require (
github.com/go-chassis/go-archaius v1.2.1
github.com/go-chassis/go-chassis v1.8.3
github.com/go-mesh/openlogging v1.0.1
github.com/huaweicse/auth v1.1.2
github.com/stretchr/testify v1.4.0
gopkg.in/yaml.v2 v2.2.4
)
310 changes: 310 additions & 0 deletions go.sum

Large diffs are not rendered by default.

0 comments on commit 2062629

Please sign in to comment.