diff --git a/examples/web/helloworld/main.go b/examples/web/helloworld/main.go index f0a68ace..043c9ec2 100644 --- a/examples/web/helloworld/main.go +++ b/examples/web/helloworld/main.go @@ -38,10 +38,10 @@ func (c *Controller) Get(at struct { at.GetMapping `value:"/"` at.Operation `id:"helloWorld" description:"This is hello world API"` at.Produces `values:"text/plain"` - Responses struct { + Responses struct { StatusOK struct { at.Response `code:"200" description:"response status OK"` - at.Schema `type:"string" description:"returns hello world message"` + at.Schema `type:"string" description:"returns hello world message"` } } }) string { diff --git a/examples/web/httpserver/statik/main.go b/examples/web/httpserver/statik/main.go index 19918d77..cac5484b 100644 --- a/examples/web/httpserver/statik/main.go +++ b/examples/web/httpserver/statik/main.go @@ -26,12 +26,18 @@ func newStaticController() *controller { } // UI serve static resource via context StaticResource method -func (c *controller) UI(at struct{ at.GetMapping `value:"/ui/*"`; at.FileServer `value:"/ui"` }, ctx context.Context) { +func (c *controller) UI(at struct { + at.GetMapping `value:"/ui/*"` + at.FileServer `value:"/ui"` +}, ctx context.Context) { return } // UI serve static resource via context StaticResource method -func (c *controller) UIIndex(at struct{ at.GetMapping `value:"/ui"`; at.FileServer `value:"/ui"` }, ctx context.Context) { +func (c *controller) UIIndex(at struct { + at.GetMapping `value:"/ui"` + at.FileServer `value:"/ui"` +}, ctx context.Context) { return } diff --git a/examples/web/httpserver/statik/main_test.go b/examples/web/httpserver/statik/main_test.go index 8e956cd7..3fba25ff 100644 --- a/examples/web/httpserver/statik/main_test.go +++ b/examples/web/httpserver/statik/main_test.go @@ -24,4 +24,4 @@ func TestController(t *testing.T) { func TestRunMain(t *testing.T) { go main() time.Sleep(100 * time.Millisecond) -} \ No newline at end of file +} diff --git a/examples/web/jaeger/publisher/main.go b/examples/web/jaeger/publisher/main.go index e36a9943..5086d001 100644 --- a/examples/web/jaeger/publisher/main.go +++ b/examples/web/jaeger/publisher/main.go @@ -31,7 +31,6 @@ import ( type Controller struct { // at.RestController or at.RestController must be embedded here at.RestController - } // Get GET /publisher/{publisher} diff --git a/examples/web/jwt/controller/foo.go b/examples/web/jwt/controller/foo.go index ee55db66..2247e888 100644 --- a/examples/web/jwt/controller/foo.go +++ b/examples/web/jwt/controller/foo.go @@ -40,8 +40,8 @@ type fooRequestParam struct { type fooResponse struct { at.ResponseBody AppNameVersion string `json:"appNameVersion"` - Greeting string `json:"greeting"` - Age int `json:"age"` + Greeting string `json:"greeting"` + Age int `json:"age"` } type fooController struct { @@ -83,8 +83,8 @@ func (c *fooController) Get(request *fooRequestParam) (response model.Response, response = new(model.BaseResponse) response.SetData(&fooResponse{ AppNameVersion: c.AppNameVersion, - Greeting: "Hello, " + request.Name, - Age: request.Age}) + Greeting: "Hello, " + request.Name, + Age: request.Age}) return } diff --git a/examples/web/jwt/service/counthandler.go b/examples/web/jwt/service/counthandler.go index f3dc544b..11e865bf 100644 --- a/examples/web/jwt/service/counthandler.go +++ b/examples/web/jwt/service/counthandler.go @@ -43,13 +43,11 @@ func (h *CountHandler) OnDisconnect() { log.Debugf("Connection with ID: %v has been disconnected!", h.connection.ID()) } - // OnPing is the websocket ping handler func (h *CountHandler) OnPing() { log.Debugf("Connection with ID: %v has been pinged!", h.connection.ID()) } - // OnPong is the websocket pong handler func (h *CountHandler) OnPong() { log.Debugf("Connection with ID: %v has been ponged!", h.connection.ID()) diff --git a/examples/web/jwt/service/statushandler.go b/examples/web/jwt/service/statushandler.go index 07a038d3..77e4c28d 100644 --- a/examples/web/jwt/service/statushandler.go +++ b/examples/web/jwt/service/statushandler.go @@ -37,15 +37,12 @@ func (h *StatusHandler) OnDisconnect() { log.Debugf("Connection with ID: %v has been disconnected!", h.connection.ID()) } - - // OnPing is the websocket ping handler func (h *StatusHandler) OnPing() { log.Debugf("Connection with ID: %v has been pinged!", h.connection.ID()) } - // OnPong is the websocket pong handler func (h *StatusHandler) OnPong() { log.Debugf("Connection with ID: %v has been ponged!", h.connection.ID()) -} \ No newline at end of file +} diff --git a/examples/web/middleware/controller/controller.go b/examples/web/middleware/controller/controller.go index 84dea000..345ee6e3 100644 --- a/examples/web/middleware/controller/controller.go +++ b/examples/web/middleware/controller/controller.go @@ -22,7 +22,7 @@ func newUserController() *UserController { } type User struct { - ID int `json:"id"` + ID int `json:"id"` Username string `json:"username"` Password string `json:"password"` } @@ -34,7 +34,7 @@ type UserResponse struct { } // GetUser -func (c *UserController) GetUser(at struct{ +func (c *UserController) GetUser(at struct { at.GetMapping `value:"/{id}"` }, id int) (response *UserResponse) { response = new(UserResponse) @@ -45,7 +45,7 @@ func (c *UserController) GetUser(at struct{ } // GetUser -func (c *UserController) DeleteUser(at struct{ +func (c *UserController) DeleteUser(at struct { at.DeleteMapping `value:"/{id}"` }, id int) (response *UserResponse) { response = new(UserResponse) @@ -53,7 +53,3 @@ func (c *UserController) DeleteUser(at struct{ response.SetMessage("Success") return } - - - - diff --git a/examples/web/middleware/controller/controller_test.go b/examples/web/middleware/controller/controller_test.go index aa333c0d..17c8303b 100644 --- a/examples/web/middleware/controller/controller_test.go +++ b/examples/web/middleware/controller/controller_test.go @@ -17,7 +17,6 @@ func TestMiddleware(t *testing.T) { Body().Contains("123456") }) - t.Run("should delete user", func(t *testing.T) { testApp.Delete("/user/123456"). Expect().Status(http.StatusOK) diff --git a/examples/web/middleware/logging/middleware.go b/examples/web/middleware/logging/middleware.go index fe001c65..779e19c9 100644 --- a/examples/web/middleware/logging/middleware.go +++ b/examples/web/middleware/logging/middleware.go @@ -21,7 +21,9 @@ func init() { // Logging is the middleware handler,it support dependency injection, method annotation // middleware handler can be annotated to specific purpose or general purpose -func (m *loggingMiddleware) Logging( at struct{at.MiddlewareHandler `value:"/" `}, ctx context.Context) { +func (m *loggingMiddleware) Logging(at struct { + at.MiddlewareHandler `value:"/" ` +}, ctx context.Context) { log.Infof("[logging middleware] %v", ctx.GetCurrentRoute()) @@ -29,4 +31,3 @@ func (m *loggingMiddleware) Logging( at struct{at.MiddlewareHandler `value:"/" ` ctx.Next() return } - diff --git a/examples/web/middleware/main.go b/examples/web/middleware/main.go index d79746cb..e97402b4 100644 --- a/examples/web/middleware/main.go +++ b/examples/web/middleware/main.go @@ -12,6 +12,6 @@ import ( func main() { // create new web application and run it web.NewApplication(). - SetProperty(app.ProfilesInclude, web.Profile, actuator.Profile,). + SetProperty(app.ProfilesInclude, web.Profile, actuator.Profile). Run() -} \ No newline at end of file +} diff --git a/examples/web/router/main.go b/examples/web/router/main.go index 404cafcb..b31a4a21 100644 --- a/examples/web/router/main.go +++ b/examples/web/router/main.go @@ -71,7 +71,9 @@ func newUserController() *UserController { } // Create -func (c *UserController) CreateUser(at struct{ at.PostMapping `value:"/"` }, +func (c *UserController) CreateUser(at struct { + at.PostMapping `value:"/"` +}, request *UserRequest) (response *UserResponse, err error) { // response @@ -88,7 +90,9 @@ func (c *UserController) CreateUser(at struct{ at.PostMapping `value:"/"` }, } // Get -func (c *UserController) GetUserByPathVariable(at struct{ at.GetMapping `value:"/{id:int}/and/{name}"` }, +func (c *UserController) GetUserByPathVariable(at struct { + at.GetMapping `value:"/{id:int}/and/{name}"` +}, id int, name string) (response *UserResponse, err error) { // response @@ -105,7 +109,9 @@ func (c *UserController) GetUserByPathVariable(at struct{ at.GetMapping `value:" } // Patch -func (c *UserController) Patch(at struct{ at.PatchMapping `value:"/{id}"` }, +func (c *UserController) Patch(at struct { + at.PatchMapping `value:"/{id}"` +}, id int) (response *UserResponse, err error) { // response @@ -114,7 +120,9 @@ func (c *UserController) Patch(at struct{ at.PatchMapping `value:"/{id}"` }, } // Delete -func (c *UserController) DeleteUser(at struct{ at.DeleteMapping `value:"/{id:int}"` }, +func (c *UserController) DeleteUser(at struct { + at.DeleteMapping `value:"/{id:int}"` +}, id int) (response *UserResponse, err error) { // response response = new(UserResponse) @@ -122,7 +130,9 @@ func (c *UserController) DeleteUser(at struct{ at.DeleteMapping `value:"/{id:int } // List -func (c *UserController) ListUser(at struct{ at.GetMapping `value:"/"` }) (response *UserResponse, err error) { +func (c *UserController) ListUser(at struct { + at.GetMapping `value:"/"` +}) (response *UserResponse, err error) { // response response = new(UserResponse) user := new(User) @@ -155,13 +165,17 @@ func newOrgController() *orgController { // GetOfficialSite // at.Method is a annotations to define request mapping for http method GET -func (c *orgController) GetOfficialSite(at struct{ at.GetMapping `value:"/official-site"` }) string { +func (c *orgController) GetOfficialSite(at struct { + at.GetMapping `value:"/official-site"` +}) string { return "https://hidevops.io" } // GetWithPathParamIdAndName // at.GetMapping is an annotation to define request mapping for http method GET, -func (c *orgController) GetWithPathVariable(at struct{ at.GetMapping `value:"/{id}/and/{name}"` }, +func (c *orgController) GetWithPathVariable(at struct { + at.GetMapping `value:"/{id}/and/{name}"` +}, id int, name string) string { return fmt.Sprintf("https://hidevops.io/%v/%v", id, name) diff --git a/examples/web/swagger/greeting-server/controller/hello.go b/examples/web/swagger/greeting-server/controller/hello.go index 416735a4..13cbaef2 100644 --- a/examples/web/swagger/greeting-server/controller/hello.go +++ b/examples/web/swagger/greeting-server/controller/hello.go @@ -21,7 +21,7 @@ func newHelloController() *controller { type HelloQueryParam struct { at.RequestParams at.Schema - Name string `schema:"defaults to World if not given"` + Name string `schema:"defaults to World if not given"` } // Hello @@ -29,8 +29,8 @@ func (c *controller) Hello(at struct { at.GetMapping `value:"/hello"` at.Operation `id:"hello" description:"This is the Greeting api for demo"` at.Produces `values:"text/plain"` - Parameters struct { - Name struct{ + Parameters struct { + Name struct { at.Parameter `type:"string" name:"name" in:"query" description:"defaults to World if not given" ` } } @@ -53,14 +53,13 @@ func (c *controller) Hello(at struct { return } - // Hey func (c *controller) Hey(at struct { at.GetMapping `value:"/hey"` at.Operation `id:"hey" description:"This is the another Greeting api for demo"` at.Produces `values:"text/plain"` - Parameters struct { - Name struct{ + Parameters struct { + Name struct { at.Parameter `type:"string" name:"name" in:"query" description:"defaults to HiBoot if not given" ` } } diff --git a/examples/web/swagger/greeting-server/controller/hello_test.go b/examples/web/swagger/greeting-server/controller/hello_test.go index 3d1ddee2..93e88286 100644 --- a/examples/web/swagger/greeting-server/controller/hello_test.go +++ b/examples/web/swagger/greeting-server/controller/hello_test.go @@ -22,4 +22,3 @@ func TestController(t *testing.T) { }) } - diff --git a/examples/web/swagger/greeting-server/main.go b/examples/web/swagger/greeting-server/main.go index b67d575e..4a9c116c 100644 --- a/examples/web/swagger/greeting-server/main.go +++ b/examples/web/swagger/greeting-server/main.go @@ -13,7 +13,7 @@ import ( ) const ( - version = "1.0.3" + version = "1.0.3" basePath = "/api/v1/greeting-server" ) @@ -24,11 +24,11 @@ func init() { ContactURL("https://hidevops.io"). Title("HiBoot Swagger Demo Application - Greeting Server"). Description("Greeting Server is an application that demonstrate the usage of Swagger Annotations"), - // alternatively, you can set below properties by using SetProperty() in main, config/application.yml or program arguments to take advantage of HiBoot DI - //Version(version). - //Schemes("http", "https"). - //Host("localhost:8080"). - //BasePath(basePath), + // alternatively, you can set below properties by using SetProperty() in main, config/application.yml or program arguments to take advantage of HiBoot DI + //Version(version). + //Schemes("http", "https"). + //Host("localhost:8080"). + //BasePath(basePath), ) } diff --git a/examples/web/swagger/greeting-server/main_test.go b/examples/web/swagger/greeting-server/main_test.go index a40aa0e6..397bb4b1 100644 --- a/examples/web/swagger/greeting-server/main_test.go +++ b/examples/web/swagger/greeting-server/main_test.go @@ -9,4 +9,3 @@ func TestRunMain(t *testing.T) { time.Sleep(1) go main() } - diff --git a/examples/web/swagger/simple-server/main.go b/examples/web/swagger/simple-server/main.go index 49be9ae9..296cde5e 100644 --- a/examples/web/swagger/simple-server/main.go +++ b/examples/web/swagger/simple-server/main.go @@ -16,15 +16,15 @@ import ( ) type Asset struct { - ID int `schema:"The asset ID" json:"id" example:"1234567890"` - Name string `schema:"The asset name" json:"name" example:"John Deng"` - Amount float64 `json:"amount" example:"987654321"` - Type string `schema:"The asset type" json:"type" example:"book"` + ID int `schema:"The asset ID" json:"id" example:"1234567890"` + Name string `schema:"The asset name" json:"name" example:"John Deng"` + Amount float64 `json:"amount" example:"987654321"` + Type string `schema:"The asset type" json:"type" example:"book"` ExpirationTime time.Time `json:"expiration_time" example:"Sun Sep 29 15:47:50 CST 2019"` } type Manager struct { - ID int `schema:"The manager ID" json:"id" default:"1000000"` + ID int `schema:"The manager ID" json:"id" default:"1000000"` Name string `schema:"The manager name of the employee" json:"name" example:"John Deng"` } @@ -41,7 +41,6 @@ type ResponseInfo struct { model.BaseResponseInfo } - type UpdateEmployeeRequest struct { at.RequestBody at.Schema @@ -102,15 +101,14 @@ func (c *employeeController) BeforeMethod(at struct{ at.BeforeMethod }, ctx cont return } - type Foo struct { at.RequestBody at.Schema - Name string `json:"name"` - Child *Foo `json:"child"` - Children []*Foo `json:"children"` - GradChildren []Foo `json:"grad_children"` + Name string `json:"name"` + Child *Foo `json:"child"` + Children []*Foo `json:"children"` + GradChildren []Foo `json:"grad_children"` } type Bar struct { @@ -118,7 +116,6 @@ type Bar struct { at.Schema Name string `json:"name"` - } // Foo @@ -127,7 +124,7 @@ func (c *employeeController) Foo(at struct { at.Operation `id:"Foo" description:"This is the foo test api"` at.Consumes `values:"application/json"` at.Produces `values:"application/json"` - at.Tags `values:"foo,bar,test"` + at.Tags `values:"foo,bar,test"` Parameters struct { at.Parameter `name:"foo" in:"body" description:"foo request body" ` Foo @@ -176,14 +173,14 @@ func (c *employeeController) Bar(at struct { // GetEmployee func (c *employeeController) CreateEmployee(at struct { - at.PostMapping `value:"/"` - at.Operation `id:"Create Employee" description:"This is the employee creation api"` - at.Consumes `values:"application/json"` - at.Produces `values:"application/json"` + at.PostMapping `value:"/"` + at.Operation `id:"Create Employee" description:"This is the employee creation api"` + at.Consumes `values:"application/json"` + at.Produces `values:"application/json"` at.ExternalDocs `url:"http://hiboot.hidevops.io" description:"HiBoot Official Site"` - Parameters struct { + Parameters struct { at.Parameter `name:"token" in:"header" type:"string" description:"JWT token (fake token - for demo only)" ` - Body struct { + Body struct { at.Parameter `name:"employee" in:"body" description:"Employee request body" ` CreateEmployeeRequest } @@ -191,10 +188,10 @@ func (c *employeeController) CreateEmployee(at struct { Responses struct { StatusOK struct { at.Response `code:"200" description:"returns a employee with ID"` - XRateLimit struct { + XRateLimit struct { at.Header `value:"X-Rate-Limit" type:"integer" format:"int32" description:"calls per hour allowed by the user"` } - XExpiresAfter struct{ + XExpiresAfter struct { at.Header `value:"X-Expires-After" type:"string" format:"date-time" description:"date in UTC when token expires"` } EmployeeResponse @@ -211,14 +208,13 @@ func (c *employeeController) CreateEmployee(at struct { return } - // GetEmployee func (c *employeeController) UpdateEmployee(at struct { at.PutMapping `value:"/"` - at.Operation `id:"Update Employee" description:"This is the employee update api"` - at.Consumes `values:"application/json"` - at.Produces `values:"application/json"` - Parameters struct { + at.Operation `id:"Update Employee" description:"This is the employee update api"` + at.Consumes `values:"application/json"` + at.Produces `values:"application/json"` + Parameters struct { at.Parameter `name:"employee" in:"body" description:"Employee request body" ` UpdateEmployeeRequest } @@ -278,7 +274,6 @@ func (c *employeeController) GetEmployee(at struct { return } - // GetEmployeeName func (c *employeeController) GetEmployeeName(at struct { at.GetMapping `value:"/{id}/name"` @@ -303,7 +298,6 @@ func (c *employeeController) GetEmployeeName(at struct { return "Donald Trump" } - // ListEmployee func (c *employeeController) ListEmployee(at struct { at.GetMapping `value:"/"` @@ -354,10 +348,10 @@ func (c *employeeController) DeleteEmployee(at struct { // AddEmployeeAsserts func (c *employeeController) AddEmployeeAsserts(at struct { at.PostMapping `value:"/add-assets"` - at.Operation `id:"Add Employee's Assets" description:"This is the api that adding assets for employees"` - at.Consumes `values:"application/json"` - at.Produces `values:"application/json"` - Parameters struct { + at.Operation `id:"Add Employee's Assets" description:"This is the api that adding assets for employees"` + at.Consumes `values:"application/json"` + at.Produces `values:"application/json"` + Parameters struct { at.Parameter `in:"body" description:"Employee request body" ` at.Schema Assets []*Asset diff --git a/examples/web/swagger/simple-server/main_test.go b/examples/web/swagger/simple-server/main_test.go index 9e86571b..9b65f505 100644 --- a/examples/web/swagger/simple-server/main_test.go +++ b/examples/web/swagger/simple-server/main_test.go @@ -113,13 +113,13 @@ func TestController(t *testing.T) { ID: 1234, Name: "abc", Amount: 1.234, - Type: "foo", + Type: "foo", ExpirationTime: time.Now(), }, { ID: 5678, Name: "def", - Type: "bar", + Type: "bar", Amount: 3.14, ExpirationTime: time.Now(), }, diff --git a/examples/web/websocket/service/counthandler.go b/examples/web/websocket/service/counthandler.go index f3dc544b..11e865bf 100644 --- a/examples/web/websocket/service/counthandler.go +++ b/examples/web/websocket/service/counthandler.go @@ -43,13 +43,11 @@ func (h *CountHandler) OnDisconnect() { log.Debugf("Connection with ID: %v has been disconnected!", h.connection.ID()) } - // OnPing is the websocket ping handler func (h *CountHandler) OnPing() { log.Debugf("Connection with ID: %v has been pinged!", h.connection.ID()) } - // OnPong is the websocket pong handler func (h *CountHandler) OnPong() { log.Debugf("Connection with ID: %v has been ponged!", h.connection.ID()) diff --git a/examples/web/websocket/service/statushandler.go b/examples/web/websocket/service/statushandler.go index 22a5c354..77e4c28d 100644 --- a/examples/web/websocket/service/statushandler.go +++ b/examples/web/websocket/service/statushandler.go @@ -37,13 +37,11 @@ func (h *StatusHandler) OnDisconnect() { log.Debugf("Connection with ID: %v has been disconnected!", h.connection.ID()) } - // OnPing is the websocket ping handler func (h *StatusHandler) OnPing() { log.Debugf("Connection with ID: %v has been pinged!", h.connection.ID()) } - // OnPong is the websocket pong handler func (h *StatusHandler) OnPong() { log.Debugf("Connection with ID: %v has been ponged!", h.connection.ID()) diff --git a/go.mod b/go.mod index e9e7faab..43c857c8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,7 @@ module hidevops.io/hiboot require ( + github.com/ajg/form v1.5.1 // indirect github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd // indirect github.com/deckarep/golang-set v1.7.1 github.com/dgrijalva/jwt-go v3.2.0+incompatible @@ -10,21 +11,21 @@ require ( github.com/go-openapi/swag v0.19.5 // indirect github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45 github.com/golang/mock v1.2.0 - github.com/golang/protobuf v1.2.0 + github.com/golang/protobuf v1.3.1 github.com/gorilla/handlers v1.4.2 github.com/gorilla/mux v1.7.0 github.com/gorilla/websocket v1.4.0 github.com/hidevopsio/mapstructure v1.1.3-0.20190908102033-f8832fd9e307 - github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1 // indirect + github.com/imkira/go-interpol v1.1.0 // indirect github.com/iris-contrib/go.uuid v2.0.0+incompatible - github.com/iris-contrib/httpexpect v0.0.0-20180314041918-ebe99fcebbce - github.com/iris-contrib/middleware v0.0.0-20171114084220-1060fbb0ce08 - github.com/kataras/golog v0.0.0-20180321173939-03be10146386 - github.com/kataras/iris v11.0.3+incompatible - github.com/kataras/pio v0.0.0-20180511174041-a9733b5b6b83 + github.com/iris-contrib/middleware/jwt v0.0.0-20191028172159-41f72a73786a + github.com/kataras/golog v0.0.9 + github.com/kataras/iris/v12 v12.0.1 + github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d + github.com/mitchellh/mapstructure v1.1.2 github.com/moul/http2curl v1.0.0 // indirect github.com/opentracing/opentracing-go v1.0.2 - github.com/pkg/errors v0.8.0 + github.com/pkg/errors v0.8.1 github.com/rakyll/statik v0.1.6 github.com/sony/sonyflake v0.0.0-20160530021500-fa881fb1052b github.com/spf13/afero v1.1.2 @@ -35,13 +36,19 @@ require ( github.com/uber/jaeger-client-go v2.15.0+incompatible github.com/uber/jaeger-lib v1.5.0+incompatible // indirect github.com/valyala/bytebufferpool v1.0.0 + github.com/valyala/fasthttp v1.6.0 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect + github.com/yudai/gojsondiff v1.0.0 // indirect + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect go.uber.org/atomic v1.3.2 // indirect golang.org/x/crypto v0.0.0-20190621222207-cc06ce4a13d4 // indirect - golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 + golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 golang.org/x/sync v0.0.0-20190423024810-112230192c58 // indirect google.golang.org/grpc v1.17.0 gopkg.in/go-playground/assert.v1 v1.2.1 // indirect gopkg.in/go-playground/validator.v8 v8.18.2 + gopkg.in/ini.v1 v1.49.0 // indirect gopkg.in/yaml.v2 v2.2.2 hidevops.io/viper v1.3.2 ) @@ -66,3 +73,5 @@ replace ( google.golang.org/genproto => github.com/google/go-genproto v0.0.0-20190215211957-bd968387e4aa google.golang.org/grpc => github.com/grpc/grpc-go v1.14.0 ) + +go 1.13 diff --git a/go.sum b/go.sum index a0883a4a..94fb1357 100644 --- a/go.sum +++ b/go.sum @@ -4,12 +4,20 @@ dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1 dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg= github.com/AndreasBriese/bbloom v0.0.0-20180913140656-343706a395b7/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= +github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a h1:3SgJcK9l5uPdBC/X17wanyJAMxM33+4ZhEIV96MIH8U= +github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= +github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible h1:rZgFj+Gtf3NMi/U5FvCvhzaxzW/TaPYgUYx3bAPz9DE= +github.com/CloudyKit/jet v2.1.3-0.20180809161101-62edd43e4f88+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a h1:PiDAizhfJbwZMISZ1Itx1ZTFeOFCml89Ofmz3V8rhoU= github.com/Joker/hpp v0.0.0-20180418125244-6893e659854a/go.mod h1:MzD2WMdSxvbHw5fM/OXOFily/lipJWRc9C1px0Mt0ZE= +github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.0.0 h1:lOCEPvTAtWfLpSZYMOv/g44MGQFAolbKh2khHHGu0Kc= github.com/Joker/jade v1.0.0/go.mod h1:efZIdO0py/LtcJRSa/j2WEklMSAw84WV0zZVMxNToB8= +github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7 h1:mreN1m/5VJ/Zc3b4pzj9qU6D9SRQ6Vm+3KfI328t3S8= +github.com/Joker/jade v1.0.1-0.20190614124447-d475f43051e7/go.mod h1:6E6s8o2AE4KhCrqr6GRJjdC/gNfTdxkIXvuGZZda2VM= github.com/PuerkitoBio/purell v1.1.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= @@ -17,8 +25,12 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/Shopify/goreferrer v0.0.0-20180807163728-b9777dc9f9cc h1:zZYkIbeMNcH1lhztdVxy4+Ykk8NoMhqUfSigsrT/x7Y= github.com/Shopify/goreferrer v0.0.0-20180807163728-b9777dc9f9cc/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= +github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398 h1:WDC6ySpJzbxGWFh4aMxFFC28wwGp5pEuoTtvA4q/qQ4= +github.com/Shopify/goreferrer v0.0.0-20181106222321-ec9c9a553398/go.mod h1:a1uqRtAwp2Xwc6WNPJEufxJ7fx3npB4UV/JOLmbu5I0= github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f h1:zvClvFQwU++UpIUBGC8YmDlfhUrweEy1R1Fj1gu5iIM= github.com/ajg/form v0.0.0-20160822230020-523a5da1a92f/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= +github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= +github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= @@ -26,6 +38,8 @@ github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4 github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/aymerick/raymond v2.0.2+incompatible h1:VEp3GpgdAnv9B2GFyTvqgcKvY+mfKMjPOA3SbKLtnU0= github.com/aymerick/raymond v2.0.2+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= +github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible h1:Ppm0npCCsmuR9oQaBtRuZcmILVE74aXE+AmrJj8L2ns= +github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= @@ -42,24 +56,33 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/deckarep/golang-set v1.7.1 h1:SCQV0S6gTtp6itiFrTqI+pfmJ4LN85S1YzhDf9rTHJQ= github.com/deckarep/golang-set v1.7.1/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= github.com/dgraph-io/badger v1.5.4/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ= +github.com/dgraph-io/badger v1.6.0/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20180109070241-2de33835d102/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o= github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM= github.com/etcd-io/bbolt v1.3.0/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= +github.com/etcd-io/bbolt v1.3.3/go.mod h1:ZF2nL25h33cCyBtcyWeZ2/I3HQOfTP+0PIEvHjkjCrw= github.com/fatih/camelcase v1.0.0 h1:hxNvNX/xYBp0ovncs8WyWZrOrpBNub/JfaMvbURyft8= github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc= github.com/fatih/structs v1.0.0 h1:BrX964Rv5uQ3wwS+KRUAJCBBw5PQmgJfJ6v4yly5QwU= github.com/fatih/structs v1.0.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/flosch/pongo2 v0.0.0-20180809100617-24195e6d38b0 h1:ZHx2BEERvWkuwuE7qWN9TuRxucHDH2JrsvneZjVJfo0= github.com/flosch/pongo2 v0.0.0-20180809100617-24195e6d38b0/go.mod h1:rE0ErqqBaMcp9pzj8JxV1GcfDBpuypXYxlR1c37AUwg= +github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 h1:GY1+t5Dr9OKADM64SYnQjw/w99HMYvQ0A8/JoUkxVmc= +github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8= +github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gavv/monotime v0.0.0-20171021193802-6f8212e8d10d h1:oYXrtNhqNKL1dVtKdv8XUq5zqdGVFNQ0/4tvccXZOLM= github.com/gavv/monotime v0.0.0-20171021193802-6f8212e8d10d/go.mod h1:vmp8DIyckQMXOPl0AQVHt+7n5h7Gb7hS6CUydiV8QeA= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -67,6 +90,7 @@ github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aev github.com/globalsign/mgo v0.0.0-20180905125535-1ca0a4f7cbcb/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8 h1:DujepqpGd1hyOd7aW59XpK7Qymp8iy83xq74fLr21is= github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8/go.mod h1:xkRDCp4j0OGD1HRkm4kmhM+pmpv3AKq5SU7GMg4oO/Q= +github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= github.com/go-openapi/analysis v0.0.0-20180825180245-b006789cd277/go.mod h1:k70tL6pCuVxPJOHXQ+wIac1FUrvNkHolPie/cLEU6hI= github.com/go-openapi/analysis v0.17.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= github.com/go-openapi/analysis v0.18.0/go.mod h1:IowGgpVeD0vNm45So8nr+IcQ3pxVtpRoBWb8PVZO0ik= @@ -109,6 +133,9 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2 h1:ky5l57HjyVRrsJfd2+Ro5Z9PjGuKbsmftwyMtk8H7js= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= +github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= +github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw= +github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45 h1:MO2DsGCZz8phRhLnpFvHEQgTH521sVN/6F2GZTbNO3Q= github.com/gojektech/valkyrie v0.0.0-20190210220504-8f62c1e7ba45/go.mod h1:tDYRk1s5Pms6XJjj5m2PxAzmQvaDU8GqDf1u6x7yxKw= @@ -128,6 +155,8 @@ github.com/golang/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:ovBFgdmJqy github.com/golang/perf v0.0.0-20190124201629-844a5f5b46f4/go.mod h1:jnf/gO64GyJNDbVRvgk/iCwNiVfNkB39iFmfJRS3T0o= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/sync v0.0.0-20181221193216-37e7f081c4d4 h1:ft59RUw3sLB8vAQoAuGD95GATmhRG73C2fQoj1iOgwo= github.com/golang/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:YCHYtYb9c8Q7XgYVYjmJBPtFPKx5QvOcPxHZWjldabE= github.com/golang/sys v0.0.0-20181029174526-d69651ed3497 h1:OUSy1n+kewL8NGp7gqHdJlFxyfckFnP7Iv9D19jopuc= @@ -136,6 +165,7 @@ github.com/golang/text v0.3.0 h1:uI5zIUA9cg047ctlTptnVc0Ghjfurf2eZMFrod8R7v8= github.com/golang/text v0.3.0/go.mod h1:GUiq9pdJKRKKAZXiVgWFEvocYuREvC14NhI4OPgEjeE= github.com/golang/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:Goyxmr1dEyuE8J10MyNptB/4WJaypDxCpNr2pf27wjI= github.com/golang/tools v0.0.0-20190214204934-8dcb7bc8c7fe/go.mod h1:E6PF97AdD6v0s+fPshSmumCW1S1Ne85RbPQxELkKa44= +github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -166,6 +196,7 @@ github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:Fecb github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= github.com/grpc/grpc-go v1.14.0 h1:mdO9QxZPgbtuMPrWCiqhyGPGLg/8E/sZpJwOOqyl134= github.com/grpc/grpc-go v1.14.0/go.mod h1:OkrsaFQVyvU0P5XR5PQ2d19rg8dJ/sIJcthuZNcktKk= +github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hidevopsio/mapstructure v1.1.3-0.20190908102033-f8832fd9e307 h1:Zc7/94OHdzC0A2sbJhrYErhhgho+fVW0qYQHarr8I+A= @@ -176,40 +207,48 @@ github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/iris-contrib/formBinder v0.0.0-20171010160137-ad9fb86c356f/go.mod h1:i8kTYUOEstd/S8TG0ChTXQdf4ermA/e8vJX0+QruD9w= -github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1 h1:7GsNnSLoVceNylMpwcfy5aFNz/S5/TV25crb34I5PEo= -github.com/iris-contrib/formBinder v0.0.0-20190104093907-fbd5963f41e1/go.mod h1:i8kTYUOEstd/S8TG0ChTXQdf4ermA/e8vJX0+QruD9w= +github.com/iris-contrib/blackfriday v2.0.0+incompatible h1:o5sHQHHm0ToHUlAJSTjW9UWicjJSDDauOOQ2AHuIVp4= +github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible h1:XZubAYg61/JwnJNbZilGjf3b3pB80+OQg2qf6c8BfWE= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= -github.com/iris-contrib/httpexpect v0.0.0-20180314041918-ebe99fcebbce h1:q8Ka/exfHNgK7izJE+aUOZd7KZXJ7oQbnJWiZakEiMo= -github.com/iris-contrib/httpexpect v0.0.0-20180314041918-ebe99fcebbce/go.mod h1:VER17o2JZqquOx41avolD/wMGQSFEFBKWmhag9/RQRY= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0 h1:Kyp9KiXwsyZRTeoNjgVCrWks7D8ht9+kg6yCjh8K97o= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= -github.com/iris-contrib/middleware v0.0.0-20171114084220-1060fbb0ce08 h1:eMdEcZQMT0Lge3x/vPRhg9wGLfdCUA3Z4wjog26HjVM= -github.com/iris-contrib/middleware v0.0.0-20171114084220-1060fbb0ce08/go.mod h1:lZivVjxn00uQH7vp452Wa2p9GD+2ElkVms944o+f0+Y= +github.com/iris-contrib/middleware/jwt v0.0.0-20191028172159-41f72a73786a h1:Oht2uZ+4vtoCV9RmnixnpeM/V6aYMBEKU3cbAYTlqLo= +github.com/iris-contrib/middleware/jwt v0.0.0-20191028172159-41f72a73786a/go.mod h1:FF5s+cHbDVeTnFC9/FR6c0QiqwU7SpGJdnUNmxq6sDw= +github.com/iris-contrib/schema v0.0.1 h1:10g/WnoRR+U+XXHWKBHeNy/+tZmM2kcAVGLOsz+yaDA= +github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.6 h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE= github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/juju/errors v0.0.0-20180806074554-22422dad46e1 h1:wnhMXidtb70kDZCeLt/EfsVtkXS5c8zLnE9y/6DIRAU= github.com/juju/errors v0.0.0-20180806074554-22422dad46e1/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= +github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= github.com/juju/loggo v0.0.0-20180524022052-584905176618 h1:MK144iBQF9hTSwBW/9eJm034bVoG30IshVm688T2hi8= github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073 h1:WQM1NildKThwdP7qWrNAFGzp4ijNLw8RlgENkaI4MJs= github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM= github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/kataras/golog v0.0.0-20180321173939-03be10146386 h1:VT6AeCHO/mc+VedKBMhoqb5eAK8B1i9F6nZl7EGlHvA= -github.com/kataras/golog v0.0.0-20180321173939-03be10146386/go.mod h1:PcaEvfvhGsqwXZ6S3CgCbmjcp+4UDUh2MIfF2ZEul8M= -github.com/kataras/iris v11.0.3+incompatible h1:dDO6AtDrusCZesEjBivmqhEGhjRN+Bzqzxdc8hXixOg= -github.com/kataras/iris v11.0.3+incompatible/go.mod h1:4cangdWZW4brINuhSqxUwRwwObNAwvqkQm3EcRDL5pA= -github.com/kataras/pio v0.0.0-20180511174041-a9733b5b6b83 h1:NoJ+fI58ptwrPc1blX116i+5xWGAY/2TJww37AN8X54= -github.com/kataras/pio v0.0.0-20180511174041-a9733b5b6b83/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= +github.com/kataras/golog v0.0.9 h1:J7Dl82843nbKQDrQM/abbNJZvQjS6PfmkkffhOTXEpM= +github.com/kataras/golog v0.0.9/go.mod h1:12HJgwBIZFNGL0EJnMRhmvGA0PQGx8VFwrZtM4CqbAk= +github.com/kataras/iris/v12 v12.0.1 h1:Wo5S7GMWv5OAzJmvFTvss/C4TS1W0uo6LkDlSymT4rM= +github.com/kataras/iris/v12 v12.0.1/go.mod h1:udK4vLQKkdDqMGJJVd/msuMtN6hpYJhg/lSzuxjhO+U= +github.com/kataras/neffos v0.0.10/go.mod h1:ZYmJC07hQPW67eKuzlfY7SO3bC0mw83A3j6im82hfqw= +github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d h1:V5Rs9ztEWdp58oayPq/ulmlqJJZeJP6pP79uP3qjcao= +github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d/go.mod h1:NV88laa9UiiDuX9AhMbDPkGYSPugBOV6yTZB1l2K9Z0= github.com/klauspost/compress v1.4.0 h1:8nsMz3tWa9SWWPL60G1V6CUsf4lLjWLTNEtibhe8gh8= github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/klauspost/compress v1.9.0 h1:GhthINjveNZAdFUD8QoQYfjxnOONZgztK/Yr6M23UTY= +github.com/klauspost/compress v1.9.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e h1:+lIPJOWl+jSiJOc70QXJ07+2eg2Jy2EC7Mi11BWujeM= github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -227,9 +266,14 @@ github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRU github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mediocregopher/mediocre-go-lib v0.0.0-20181029021733-cb65787f37ed/go.mod h1:dSsfyI2zABAdhcbvkXqgxOxrCsbYeHCPgrZkku60dSg= +github.com/mediocregopher/radix/v3 v3.3.0/go.mod h1:EmfVyvspXz1uZEyPBMyGK+kjWiKQGvsUt6O3Pj+LDCQ= github.com/microcosm-cc/bluemonday v1.0.1 h1:SIYunPjnlXcW+gVfvm0IlSeR5U3WZUOLfVmqg85Go44= github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= +github.com/microcosm-cc/bluemonday v1.0.2 h1:5lPfLTTAvAbtS0VqT+94yOtFnGfUWYyx0+iToC3Os3s= +github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.0.0/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= @@ -241,6 +285,9 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb github.com/moul/http2curl v0.0.0-20170919181001-9ac6cf4d929b/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= +github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= +github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= github.com/onsi/ginkgo v1.6.0 h1:Ix8l273rp3QzYgXSR+c8d1fTG7UPgYkOSELPhiY/YGw= @@ -255,6 +302,8 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181 github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -289,6 +338,8 @@ github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5J github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY= github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= @@ -332,12 +383,17 @@ github.com/uber/jaeger-lib v1.5.0+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6 github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.6.0 h1:uWF8lgKmeaIewWVPwi4GRq2P6+R46IgYZdxWtM+GtEY= +github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w= +github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v0.0.0-20180816142147-da425ebb7609 h1:BcMExZAULPkihVZ7UJXK7t8rwGqisXFw75tILnafhBY= github.com/xeipuuv/gojsonschema v0.0.0-20180816142147-da425ebb7609/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= @@ -364,6 +420,8 @@ gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/R gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/ini.v1 v1.38.3 h1:ourkRZgR6qjJYoec9lYhX4+nuN1tEbV34dQEQ3IRk9U= gopkg.in/ini.v1 v1.38.3/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.49.0 h1:MW0aLMiezbm/Ray0gJJ+nQFE2uOC9EpK2p5zPN3NqpM= +gopkg.in/ini.v1 v1.49.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/russross/blackfriday.v2 v2.0.0+incompatible h1:l1Mna0cVh8WlpyB8uFtc2c+5cdvrI5CDyuwTgIChojI= diff --git a/pkg/app/application.go b/pkg/app/application.go index 7b5a4574..caec3c70 100644 --- a/pkg/app/application.go +++ b/pkg/app/application.go @@ -33,11 +33,11 @@ import ( const ( // ApplicationContextName is the application context instance name - ApplicationContextName = "app.applicationContext" - ContextPathFormat = "server.context_path_format" - ContextPathFormatKebab = "kebab" - ContextPathFormatSnake = "snake" - ContextPathFormatCamel = "camel" + ApplicationContextName = "app.applicationContext" + ContextPathFormat = "server.context_path_format" + ContextPathFormatKebab = "kebab" + ContextPathFormatSnake = "snake" + ContextPathFormatCamel = "camel" ContextPathFormatLowerCamel = "lower-camel" ) diff --git a/pkg/app/application_test.go b/pkg/app/application_test.go index f2cb3181..3b56e9a8 100644 --- a/pkg/app/application_test.go +++ b/pkg/app/application_test.go @@ -93,8 +93,11 @@ func TestApp(t *testing.T) { t.Run("should add new named component", func(t *testing.T) { type fakeService interface{} - type fakeServiceImpl struct{ at.Qualifier `value:"myService"`; fakeService } - app.Register(new(fakeServiceImpl)) + type fakeServiceImpl struct { + at.Qualifier `value:"myService"` + fakeService + } + app.Register(new(fakeServiceImpl)) }) t.Run("should add more than one new component at the same time", func(t *testing.T) { diff --git a/pkg/app/cli/application_test.go b/pkg/app/cli/application_test.go index 5e93a851..7373f42c 100644 --- a/pkg/app/cli/application_test.go +++ b/pkg/app/cli/application_test.go @@ -210,8 +210,6 @@ func TestAB(t *testing.T) { b.Run("hello") } - - type circularFoo struct { circularBar *circularBar } @@ -261,4 +259,3 @@ func TestApplicationWithCircularDI(t *testing.T) { assert.Equal(t, nil, err) }) } - diff --git a/pkg/app/web/application.go b/pkg/app/web/application.go index 81727e0e..a2e775b6 100644 --- a/pkg/app/web/application.go +++ b/pkg/app/web/application.go @@ -17,7 +17,7 @@ package web import ( "errors" "fmt" - "github.com/kataras/iris" + "github.com/kataras/iris/v12" "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/app/web/context" "hidevops.io/hiboot/pkg/at" diff --git a/pkg/app/web/application_test.go b/pkg/app/web/application_test.go index f041edd5..2ef3df60 100644 --- a/pkg/app/web/application_test.go +++ b/pkg/app/web/application_test.go @@ -181,7 +181,6 @@ func (c *FooController) GetByOptions(options []string) (response model.Response) return } - // GET /foo/fs func (c *FooController) GetFs(fs []*Foo) (response model.Response) { response = new(model.BaseResponse) @@ -312,10 +311,10 @@ func (c *FooController) GetErr() float32 { return 0.01 } - type Foo struct { Name string } + // Get test get func (c *FooController) GetInjection(foo *Foo) string { log.Debug(foo) @@ -802,7 +801,7 @@ func TestWebApplication(t *testing.T) { { Name: "bar", }, - }). + }). Expect().Status(http.StatusOK). Body().Contains("foo") }) @@ -933,8 +932,9 @@ func newConditionalFakeJwtMiddleware() *fakeConditionalJwtMiddleware { } // CheckJwt -func (m *fakeConditionalJwtMiddleware) CheckJwt(at struct{ at.MiddlewareHandler -}, ctx context.Context) { +func (m *fakeConditionalJwtMiddleware) CheckJwt(at struct { + at.MiddlewareHandler +}, ctx context.Context) { log.Debug("fakeConditionalJwtMiddleware.CheckJwt()") if ctx.URLParam("token") == "" { ctx.StatusCode(http.StatusUnauthorized) @@ -953,10 +953,10 @@ func newMethodConditionalFakeJwtMiddleware() *fakeMethodConditionalJwtMiddleware } // CheckJwt -func (m *fakeMethodConditionalJwtMiddleware) CheckJwt(at struct{ +func (m *fakeMethodConditionalJwtMiddleware) CheckJwt(at struct { at.MiddlewareHandler at.UseJwt -}, ctx context.Context) { +}, ctx context.Context) { log.Debug("fakeMethodConditionalJwtMiddleware.CheckJwt()") if ctx.URLParam("token") == "" { ctx.StatusCode(http.StatusUnauthorized) @@ -966,7 +966,6 @@ func (m *fakeMethodConditionalJwtMiddleware) CheckJwt(at struct{ return } - type fooMiddleware struct { at.Middleware } @@ -977,7 +976,9 @@ func newFooMiddleware() *fooMiddleware { // Logging is the middleware handler,it support dependency injection, method annotation // middleware handler can be annotated to specific purpose or general purpose -func (m *fooMiddleware) Logging( at struct{at.MiddlewareHandler `value:"/" `}, ctx context.Context) { +func (m *fooMiddleware) Logging(at struct { + at.MiddlewareHandler `value:"/" ` +}, ctx context.Context) { log.Infof("[logging middleware] %v", ctx.GetCurrentRoute()) @@ -1004,9 +1005,9 @@ func newCustomRouterController() *customRouterController { func (c *customRouterController) PathVariable( at struct { - // at.GetMapping is an annotation to define request mapping for http method GET /{id}/and/{name} - at.GetMapping `value:"/{id}/name/{name}"` -}, id int, name string) (response *CustomResponse, err error) { + // at.GetMapping is an annotation to define request mapping for http method GET /{id}/and/{name} + at.GetMapping `value:"/{id}/name/{name}"` + }, id int, name string) (response *CustomResponse, err error) { response = new(CustomResponse) log.Infof("PathParamIdAndName: %v", at.AtValue) switch id { @@ -1027,11 +1028,11 @@ func (c *customRouterController) PathVariable( func (c *customRouterController) Delete( at struct { - // at.GetMapping is an annotation to define request mapping for http method GET /{id}/and/{name} - at.DeleteMapping `value:"/{id}"` - // uses jwt auth, it can be placed in struct of method - at.UseJwt -}, id int,) (response *CustomResponse, err error) { + // at.GetMapping is an annotation to define request mapping for http method GET /{id}/and/{name} + at.DeleteMapping `value:"/{id}"` + // uses jwt auth, it can be placed in struct of method + at.UseJwt + }, id int) (response *CustomResponse, err error) { response = new(CustomResponse) log.Infof("Delete: %v", at.DeleteMapping.AtValue) @@ -1041,13 +1042,13 @@ func (c *customRouterController) Delete( } // BeforeMethod -func (c *customRouterController) BeforeMethod(at struct{ at.BeforeMethod}, ctx context.Context) { +func (c *customRouterController) BeforeMethod(at struct{ at.BeforeMethod }, ctx context.Context) { ctx.Next() return } // AfterMethod -func (c *customRouterController) AfterMethod(at struct{ at.AfterMethod }) { +func (c *customRouterController) AfterMethod(at struct{ at.AfterMethod }) { return } @@ -1062,12 +1063,16 @@ func newJwtAuthTestController() *jwtAuthTestController { } // Get -func (c *jwtAuthTestController) Get(at struct{ at.GetMapping `value:"/"` }) string { +func (c *jwtAuthTestController) Get(at struct { + at.GetMapping `value:"/"` +}) string { return "Get from jwt auth test controller" } // Delete -func (c *jwtAuthTestController) Delete(at struct{ at.DeleteMapping `value:"/"` }) string { +func (c *jwtAuthTestController) Delete(at struct { + at.DeleteMapping `value:"/"` +}) string { return "Delete from jwt auth test controller" } @@ -1085,7 +1090,9 @@ func newRegularTestController() *regularTestController { } // Get -func (c *regularTestController) Get(at struct{ at.GetMapping `value:"/"` }) string { +func (c *regularTestController) Get(at struct { + at.GetMapping `value:"/"` +}) string { return "regularTestController.Get()" } @@ -1110,7 +1117,7 @@ func newFakeSubscriber() *fakeSubscriber { return &fakeSubscriber{} } -func (s *fakeSubscriber) Subscribe(atc *annotation.Annotations, atm *annotation.Annotations) { +func (s *fakeSubscriber) Subscribe(atc *annotation.Annotations, atm *annotation.Annotations) { log.Debug("subscribe") } @@ -1177,18 +1184,27 @@ func newPublicTestController() *publicTestController { } // UI serve static resource via context StaticResource method -func (c *publicTestController) UI(at struct{ at.GetMapping `value:"/ui/*"`; at.FileServer `value:"/ui"` }, ctx context.Context) { +func (c *publicTestController) UI(at struct { + at.GetMapping `value:"/ui/*"` + at.FileServer `value:"/ui"` +}, ctx context.Context) { return } // UI serve static resource via context StaticResource method -func (c *publicTestController) UIIndex(at struct{ at.GetMapping `value:"/ui"`; at.FileServer `value:"/ui"` }, ctx context.Context) { +func (c *publicTestController) UIIndex(at struct { + at.GetMapping `value:"/ui"` + at.FileServer `value:"/ui"` +}, ctx context.Context) { return } // UI serve static resource via context StaticResource method -func (c *publicTestController) NotFound(at struct{ at.GetMapping `value:"/foo"`; at.FileServer `value:"/ui"` }, ctx context.Context) { - ctx.WrapHandler( http.NotFoundHandler() ) +func (c *publicTestController) NotFound(at struct { + at.GetMapping `value:"/foo"` + at.FileServer `value:"/ui"` +}, ctx context.Context) { + ctx.WrapHandler(http.NotFoundHandler()) } func TestController(t *testing.T) { diff --git a/pkg/app/web/autoconfigure.go b/pkg/app/web/autoconfigure.go index 6fbc60f6..4ac0bbc5 100644 --- a/pkg/app/web/autoconfigure.go +++ b/pkg/app/web/autoconfigure.go @@ -2,7 +2,7 @@ package web import ( "fmt" - "github.com/kataras/iris" + "github.com/kataras/iris/v12" "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/app/web/context" "hidevops.io/hiboot/pkg/at" diff --git a/pkg/app/web/context.go b/pkg/app/web/context.go index 67279357..4cbaeb85 100644 --- a/pkg/app/web/context.go +++ b/pkg/app/web/context.go @@ -15,16 +15,18 @@ package web import ( - "github.com/kataras/iris" "sync" - ctx "github.com/kataras/iris/context" - "github.com/kataras/iris/middleware/i18n" + "github.com/kataras/iris/v12" + + "net/http" + + ctx "github.com/kataras/iris/v12/context" + "github.com/kataras/iris/v12/middleware/i18n" "hidevops.io/hiboot/pkg/app/web/context" "hidevops.io/hiboot/pkg/model" "hidevops.io/hiboot/pkg/utils/mapstruct" "hidevops.io/hiboot/pkg/utils/validator" - "net/http" ) // Context Create your own custom Context, put any fields you wanna need. @@ -85,17 +87,17 @@ func (c *Context) Next() { //} // WrapHandler is a helper function for wrapping http.Handler -func (c *Context) WrapHandler(h http.Handler) { +func (c *Context) WrapHandler(h http.Handler) { h.ServeHTTP(c.ResponseWriter(), c.Request()) } // HTML Override any context's method you want... // [...] -func (c *Context) HTML(htmlContents string) (int, error) { +func (c *Context) HTML(htmlContents string, args ...interface{}) (int, error) { c.Application().Logger().Infof("Executing .HTML function from Context") c.ContentType("text/html") - return c.WriteString(htmlContents) + return c.Writef(htmlContents, args...) } // handle i18n diff --git a/pkg/app/web/context/context.go b/pkg/app/web/context/context.go index 84bfa360..66a17d84 100644 --- a/pkg/app/web/context/context.go +++ b/pkg/app/web/context/context.go @@ -1,8 +1,8 @@ package context import ( - "github.com/kataras/iris" - "github.com/kataras/iris/context" + "github.com/kataras/iris/v12" + "github.com/kataras/iris/v12/context" "net/http" ) diff --git a/pkg/app/web/defaultconfig.go b/pkg/app/web/defaultconfig.go index fdc14ea2..1d21cf75 100644 --- a/pkg/app/web/defaultconfig.go +++ b/pkg/app/web/defaultconfig.go @@ -1,6 +1,6 @@ package web -import "github.com/kataras/iris" +import "github.com/kataras/iris/v12" // DefaultConfiguration returns the default configuration for an iris station, fills the main Configuration func defaultConfiguration() iris.Configuration { diff --git a/pkg/app/web/dispatcher.go b/pkg/app/web/dispatcher.go index 313a0423..f18be8b2 100644 --- a/pkg/app/web/dispatcher.go +++ b/pkg/app/web/dispatcher.go @@ -17,7 +17,7 @@ package web import ( "fmt" "github.com/fatih/camelcase" - "github.com/kataras/iris" + "github.com/kataras/iris/v12" "github.com/rakyll/statik/fs" "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/app/web/context" @@ -58,8 +58,8 @@ type Dispatcher struct { webApp *webApp // inject context aware dependencies configurableFactory factory.ConfigurableFactory - SystemApp *system.App - SystemServer *system.Server + SystemApp *system.App + SystemServer *system.Server ContextPathFormat string `value:"${server.context_path_format}" ` diff --git a/pkg/app/web/handler.go b/pkg/app/web/handler.go index f517a38d..195552fd 100644 --- a/pkg/app/web/handler.go +++ b/pkg/app/web/handler.go @@ -57,12 +57,12 @@ type request struct { } type response struct { - typeName string - name string - kind reflect.Kind - typ reflect.Type - isResponseBody bool - implementsResponse bool + typeName string + name string + kind reflect.Kind + typ reflect.Type + isResponseBody bool + implementsResponse bool implementsResponseInfo bool } diff --git a/pkg/app/web/handler_test.go b/pkg/app/web/handler_test.go index d5a0b1f7..034d1ce7 100644 --- a/pkg/app/web/handler_test.go +++ b/pkg/app/web/handler_test.go @@ -15,7 +15,7 @@ package web import ( - "github.com/kataras/iris" + "github.com/kataras/iris/v12" "github.com/stretchr/testify/assert" "hidevops.io/hiboot/pkg/at" "hidevops.io/hiboot/pkg/factory" @@ -92,5 +92,4 @@ func TestParse(t *testing.T) { assert.Equal(t, "/", p) }) - } diff --git a/pkg/app/web/method_subscriber.go b/pkg/app/web/method_subscriber.go index 07df56f4..6cb54ae3 100644 --- a/pkg/app/web/method_subscriber.go +++ b/pkg/app/web/method_subscriber.go @@ -5,4 +5,4 @@ import "hidevops.io/hiboot/pkg/inject/annotation" // HttpMethodSubscriber type HttpMethodSubscriber interface { Subscribe(atController *annotation.Annotations, atMethod *annotation.Annotations) -} \ No newline at end of file +} diff --git a/pkg/app/web/testapplication.go b/pkg/app/web/testapplication.go index 328a00a3..293017b6 100644 --- a/pkg/app/web/testapplication.go +++ b/pkg/app/web/testapplication.go @@ -18,8 +18,7 @@ import ( "net/http" "testing" - "github.com/iris-contrib/httpexpect" - "github.com/kataras/iris/httptest" + "github.com/kataras/iris/v12/httptest" "github.com/stretchr/testify/assert" "hidevops.io/hiboot/pkg/log" ) @@ -29,19 +28,19 @@ type TestApplication interface { Initialize() error SetProperty(name string, value ...interface{}) TestApplication Run(t *testing.T) TestApplication - Request(method, path string, pathargs ...interface{}) *httpexpect.Request - Post(path string, pathargs ...interface{}) *httpexpect.Request - Get(path string, pathargs ...interface{}) *httpexpect.Request - Put(path string, pathargs ...interface{}) *httpexpect.Request - Delete(path string, pathargs ...interface{}) *httpexpect.Request - Patch(path string, pathargs ...interface{}) *httpexpect.Request - Options(path string, pathargs ...interface{}) *httpexpect.Request + Request(method, path string, pathargs ...interface{}) *httptest.Request + Post(path string, pathargs ...interface{}) *httptest.Request + Get(path string, pathargs ...interface{}) *httptest.Request + Put(path string, pathargs ...interface{}) *httptest.Request + Delete(path string, pathargs ...interface{}) *httptest.Request + Patch(path string, pathargs ...interface{}) *httptest.Request + Options(path string, pathargs ...interface{}) *httptest.Request } // TestApplication the test web application for unit test only type testApplication struct { application - expect *httpexpect.Expect + expect *httptest.Expect } // RunTestApplication returns the new test application @@ -85,36 +84,36 @@ func (a *testApplication) Run(t *testing.T) TestApplication { } // Request request for unit test -func (a *testApplication) Request(method, path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Request(method, path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(method, path, pathargs...) } // Post wrap of Request with POST method -func (a *testApplication) Post(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Post(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodPost, path, pathargs...) } // Put wrap of Request with Put method -func (a *testApplication) Put(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Put(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodPut, path, pathargs...) } // Patch wrap of Request with Patch method -func (a *testApplication) Patch(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Patch(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodPatch, path, pathargs...) } // Get wrap of Request with Get method -func (a *testApplication) Get(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Get(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodGet, path, pathargs...) } // Delete wrap of Request with Delete method -func (a *testApplication) Delete(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Delete(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodDelete, path, pathargs...) } // Delete wrap of Request with Delete method -func (a *testApplication) Options(path string, pathargs ...interface{}) *httpexpect.Request { +func (a *testApplication) Options(path string, pathargs ...interface{}) *httptest.Request { return a.expect.Request(http.MethodOptions, path, pathargs...) } diff --git a/pkg/app/web/webutils/utils_test.go b/pkg/app/web/webutils/utils_test.go index eacce7e8..bd0a685e 100644 --- a/pkg/app/web/webutils/utils_test.go +++ b/pkg/app/web/webutils/utils_test.go @@ -10,14 +10,30 @@ import ( func TestUtils(t *testing.T) { testData := []interface{}{ - &struct{ at.GetMapping `value:"/"` }{}, - &struct{ at.PostMapping `value:"/"` }{}, - &struct{ at.PutMapping `value:"/"` }{}, - &struct{ at.DeleteMapping `value:"/"` }{}, - &struct{ at.PatchMapping `value:"/"` }{}, - &struct{ at.OptionsMapping `value:"/"` }{}, - &struct{ at.AnyMapping `value:"/"` }{}, - &struct{ at.TraceMapping `value:"/"` }{}, + &struct { + at.GetMapping `value:"/"` + }{}, + &struct { + at.PostMapping `value:"/"` + }{}, + &struct { + at.PutMapping `value:"/"` + }{}, + &struct { + at.DeleteMapping `value:"/"` + }{}, + &struct { + at.PatchMapping `value:"/"` + }{}, + &struct { + at.OptionsMapping `value:"/"` + }{}, + &struct { + at.AnyMapping `value:"/"` + }{}, + &struct { + at.TraceMapping `value:"/"` + }{}, } for _, a := range testData { diff --git a/pkg/at/application.go b/pkg/at/application.go index 1fa1ae6a..ecc1eeaa 100644 --- a/pkg/at/application.go +++ b/pkg/at/application.go @@ -5,4 +5,4 @@ type HiBootApplication struct { Annotation BaseAnnotation -} \ No newline at end of file +} diff --git a/pkg/at/middleware.go b/pkg/at/middleware.go index 4f400622..30979325 100644 --- a/pkg/at/middleware.go +++ b/pkg/at/middleware.go @@ -26,4 +26,4 @@ type UseJwt struct { Annotation UseMiddleware -} \ No newline at end of file +} diff --git a/pkg/at/request.go b/pkg/at/request.go index e65fe7c1..bbe85911 100644 --- a/pkg/at/request.go +++ b/pkg/at/request.go @@ -8,7 +8,7 @@ type RequestBody struct { } // RequestForm the annotation RequestForm -type RequestForm struct{ +type RequestForm struct { Annotation BaseAnnotation diff --git a/pkg/at/restcontroller.go b/pkg/at/restcontroller.go index c625409f..7d726a59 100644 --- a/pkg/at/restcontroller.go +++ b/pkg/at/restcontroller.go @@ -30,7 +30,7 @@ type JwtRestController struct { UseJwt } -type HttpMethodSubscriber struct{ +type HttpMethodSubscriber struct { Annotation BaseAnnotation @@ -91,7 +91,7 @@ type PostMapping struct { Annotation RequestMapping - AtMethod string `method:"POST" at:"method" json:"-"` + AtMethod string `method:"POST" at:"method" json:"-"` } // PutMapping is the annotation that set the PutMapping of a controller @@ -99,7 +99,7 @@ type PutMapping struct { Annotation RequestMapping - AtMethod string `method:"PUT" at:"method" json:"-"` + AtMethod string `method:"PUT" at:"method" json:"-"` } // PatchMapping is the annotation that set the PatchMapping of a controller @@ -107,7 +107,7 @@ type PatchMapping struct { Annotation RequestMapping - AtMethod string `method:"PATCH" at:"method" json:"-"` + AtMethod string `method:"PATCH" at:"method" json:"-"` } // DeleteMapping is the annotation that set the DeleteMapping of a controller @@ -115,7 +115,7 @@ type DeleteMapping struct { Annotation RequestMapping - AtMethod string `method:"DELETE" at:"method" json:"-"` + AtMethod string `method:"DELETE" at:"method" json:"-"` } // AnyMapping is the annotation that set the AnyMapping of a controller @@ -123,7 +123,7 @@ type AnyMapping struct { Annotation RequestMapping - AtMethod string `value:"ANY" at:"method" json:"-"` + AtMethod string `value:"ANY" at:"method" json:"-"` } // OptionsMapping is the annotation that set the OptionsMapping of a controller @@ -131,7 +131,7 @@ type OptionsMapping struct { Annotation RequestMapping - AtMethod string `method:"OPTIONS" at:"method" json:"-"` + AtMethod string `method:"OPTIONS" at:"method" json:"-"` } // TraceMapping is the annotation that set the TraceMapping of a controller @@ -139,7 +139,7 @@ type TraceMapping struct { Annotation RequestMapping - AtMethod string `method:"TRACE" at:"method" json:"-"` + AtMethod string `method:"TRACE" at:"method" json:"-"` } // StaticResource is the annotation that set the StaticResource of a controller @@ -148,4 +148,4 @@ type FileServer struct { Annotation RequestMapping -} \ No newline at end of file +} diff --git a/pkg/at/restcontroller_test.go b/pkg/at/restcontroller_test.go index 5f48aeb2..85ff9704 100644 --- a/pkg/at/restcontroller_test.go +++ b/pkg/at/restcontroller_test.go @@ -9,10 +9,10 @@ import ( func TestRestControllerAnnotations(t *testing.T) { t.Run("should pass test for annotation RequestMapping", func(t *testing.T) { - rm := RequestMapping{HttpMethod:HttpMethod{BaseAnnotation: BaseAnnotation{AtValue:"/foo"}}} + rm := RequestMapping{HttpMethod: HttpMethod{BaseAnnotation: BaseAnnotation{AtValue: "/foo"}}} assert.Equal(t, rm.BaseAnnotation.AtValue, "/foo") - assert.Equal(t, rm, RequestMapping{HttpMethod:HttpMethod{BaseAnnotation: BaseAnnotation{AtValue:"/foo"}}}) + assert.Equal(t, rm, RequestMapping{HttpMethod: HttpMethod{BaseAnnotation: BaseAnnotation{AtValue: "/foo"}}}) }) } diff --git a/pkg/at/swagger.go b/pkg/at/swagger.go index 624d45ea..a00c2416 100644 --- a/pkg/at/swagger.go +++ b/pkg/at/swagger.go @@ -23,10 +23,10 @@ type Operation struct { Swagger - AtID string `at:"id" json:"-"` + AtID string `at:"id" json:"-"` AtDescription string `at:"description" json:"-"` - AtSummary string `at:"summary" json:"-"` - AtDeprecated bool `at:"deprecated" json:"-"` + AtSummary string `at:"summary" json:"-"` + AtDeprecated bool `at:"deprecated" json:"-"` } // Tags @@ -62,9 +62,9 @@ type Parameter struct { Swagger - AtName string `at:"name" json:"-"` - AtType string `at:"type" json:"-"` - AtIn string `at:"in" json:"-"` + AtName string `at:"name" json:"-"` + AtType string `at:"type" json:"-"` + AtIn string `at:"in" json:"-"` AtDescription string `at:"description" json:"-"` } @@ -75,7 +75,7 @@ type Parameter struct { // at struct { // at.Consumes `values:"application/json,application/xml"` // } -type Produces struct{ +type Produces struct { Annotation Swagger @@ -90,7 +90,7 @@ type Produces struct{ // at struct { // at.Consumes `values:"application/json,application/xml"` // } -type Consumes struct{ +type Consumes struct { Annotation Swagger @@ -115,7 +115,7 @@ type Response struct { Swagger - AtCode int `at:"code" json:"-"` + AtCode int `at:"code" json:"-"` AtDescription string `at:"description" json:"-"` } @@ -136,18 +136,17 @@ type Schema struct { Swagger - AtType string `at:"type" json:"-"` + AtType string `at:"type" json:"-"` AtDescription string `at:"description" json:"-"` } // Header is the annotation that annotate the header -type Header struct{ +type Header struct { Annotation Swagger - AtType string `at:"type" json:"-"` - AtFormat string `at:"format" json:"-"` + AtType string `at:"type" json:"-"` + AtFormat string `at:"format" json:"-"` AtDescription string `at:"description" json:"-"` } - diff --git a/pkg/at/swagger_test.go b/pkg/at/swagger_test.go index a8c5bf4c..650c061e 100644 --- a/pkg/at/swagger_test.go +++ b/pkg/at/swagger_test.go @@ -14,7 +14,7 @@ func TestMarshal(t *testing.T) { } foo := &Foo{ - Name: "foo", + Name: "foo", } b, err := json.Marshal(foo) @@ -28,4 +28,4 @@ func TestMarshal(t *testing.T) { assert.Equal(t, nil, err) assert.Equal(t, "foo", backFoo.Name) -} \ No newline at end of file +} diff --git a/pkg/factory/autoconfigure/configurable_test.go b/pkg/factory/autoconfigure/configurable_test.go index b864ea1f..7b5a8295 100644 --- a/pkg/factory/autoconfigure/configurable_test.go +++ b/pkg/factory/autoconfigure/configurable_test.go @@ -94,7 +94,6 @@ type foobarProperties struct { Username string `default:"fb"` } - type barProperties struct { at.ConfigurationProperties `value:"bar"` @@ -221,8 +220,8 @@ type FooBar struct { type barConfiguration struct { at.AutoConfiguration - - barProperties *barProperties + + barProperties *barProperties } func newBarConfiguration(barProperties *barProperties) *barConfiguration { @@ -240,7 +239,7 @@ func init() { type fakeConfiguration struct { app.Configuration - FakeProperties *FakeProperties + FakeProperties *FakeProperties } func newFakeConfiguration(fakeProperties *FakeProperties) *fakeConfiguration { @@ -443,7 +442,7 @@ func TestConfigurableFactory(t *testing.T) { _, err = f.BuildProperties() assert.Equal(t, nil, err) }) - + f.Build([]*factory.MetaData{ factory.NewMetaData(newEmptyConfiguration), factory.NewMetaData(newFakeConfiguration), @@ -521,7 +520,6 @@ func TestReplacer(t *testing.T) { assert.Equal(t, nil, err) }) - type outConfiguration struct { at.AutoConfiguration Properties *fooProperties `inject:""` @@ -536,7 +534,7 @@ func TestReplacer(t *testing.T) { fp := f.GetInstance(fooProperties{}) assert.NotEqual(t, nil, fp) fooProp := fp.(*fooProperties) - + t.Run("should get foo configuration", func(t *testing.T) { assert.Equal(t, "hiboot-test foo", fooProp.Nickname) assert.Equal(t, "bar", fooProp.Username) diff --git a/pkg/factory/instantiate/instantiate.go b/pkg/factory/instantiate/instantiate.go index c39a5d63..7aa5b9ad 100644 --- a/pkg/factory/instantiate/instantiate.go +++ b/pkg/factory/instantiate/instantiate.go @@ -82,7 +82,6 @@ func NewInstantiateFactory(instanceMap cmap.ConcurrentMap, components []*factory sl := new(system.Logging) syscfg := system.NewConfiguration(sa, ss, sl) - customProps := defaultProperties.Items() f.builder = system.NewPropertyBuilder( filepath.Join(workDir, config), diff --git a/pkg/factory/instantiate/instantiate_test.go b/pkg/factory/instantiate/instantiate_test.go index 5b5bec36..60ffb0bd 100644 --- a/pkg/factory/instantiate/instantiate_test.go +++ b/pkg/factory/instantiate/instantiate_test.go @@ -360,7 +360,6 @@ func newContextAwareObject(ctx context.Context) *contextAwareFuncObject { } type foo struct { - } func (f *foo) ContextAwareMethodObject(ctx context.Context) *contextAwareMethodObject { diff --git a/pkg/factory/metadata_test.go b/pkg/factory/metadata_test.go index 05db5d9f..1e3adb33 100644 --- a/pkg/factory/metadata_test.go +++ b/pkg/factory/metadata_test.go @@ -11,7 +11,7 @@ import ( type foo struct { at.Qualifier `value:"foo"` - name string + name string } type fooBarService struct { diff --git a/pkg/inject/annotation/annotation.go b/pkg/inject/annotation/annotation.go index 1873e795..5396ffb9 100644 --- a/pkg/inject/annotation/annotation.go +++ b/pkg/inject/annotation/annotation.go @@ -28,22 +28,22 @@ import ( ) // annotation field -type Field struct{ +type Field struct { StructField reflect.StructField - Value reflect.Value + Value reflect.Value } -type Annotation struct{ - Field *Field +type Annotation struct { + Field *Field Parent *types.ReflectObject } -type Annotations struct{ +type Annotations struct { Items []*Annotation Children []*Annotations } -func IsAnnotation(object interface{}) (yes bool) { +func IsAnnotation(object interface{}) (yes bool) { typ, ok := reflector.GetObjectType(object) if !ok { return @@ -141,7 +141,7 @@ func GetAnnotations(object interface{}) (annotations *Annotations) { _, ok = reflector.GetEmbeddedFieldByType(typ, at.Annotation{}, reflect.Struct) if ok { //log.Debugf("%v %v %v", ov.IsValid(), ov.CanAddr(), ov.Type().Kind()) - if ov.IsValid() && ov.CanAddr() && ov.Type().Kind() == reflect.Struct{ + if ov.IsValid() && ov.CanAddr() && ov.Type().Kind() == reflect.Struct { ann.Field.Value = ov.FieldByName(f.Name) } ann.Field.StructField = f @@ -171,7 +171,7 @@ func FilterIn(input *Annotations, att interface{}) (annotations []*Annotation) { for _, item := range input.Items { if item.Field.Value.IsValid() { ok = item.Field.StructField.Type == reflect.TypeOf(att) - ok = ok || reflector.HasEmbeddedFieldType(item.Field.Value.Interface(), att) + ok = ok || reflector.HasEmbeddedFieldType(item.Field.Value.Interface(), att) if ok { annotations = append(annotations, item) } @@ -262,7 +262,7 @@ func InjectAll(object interface{}) (err error) { return } -func addTags(tags *structtag.Tags, typ reflect.Type) () { +func addTags(tags *structtag.Tags, typ reflect.Type) { for _, f := range reflector.DeepFields(typ) { tgs, e := structtag.Parse(string(f.Tag)) if e == nil { @@ -286,7 +286,7 @@ func injectIntoField(field *Field) (err error) { } addTags(tags, field.StructField.Type) - fieldValue := field.Value + fieldValue := field.Value typeField, ok := fieldValue.Type().FieldByName("FieldName") if ok { valueFieldName := typeField.Tag.Get("value") @@ -295,7 +295,7 @@ func injectIntoField(field *Field) (err error) { if valueFieldValue.CanSet() { switch valueFieldValue.Interface().(type) { case map[int]string: - values := make( map[int]string) + values := make(map[int]string) for _, tag := range tags.Tags() { k := str.Convert(tag.Key, reflect.Int).(int) values[k] = tag.Name @@ -303,7 +303,7 @@ func injectIntoField(field *Field) (err error) { valueFieldValue.Set(reflect.ValueOf(values)) return case map[string]string: - values := make( map[string]string) + values := make(map[string]string) for _, tag := range tags.Tags() { values[tag.Key] = tag.Name } @@ -316,7 +316,7 @@ func injectIntoField(field *Field) (err error) { // iterate over all tags if tags != nil { - values := make( map[string]interface{}) + values := make(map[string]interface{}) for _, tag := range tags.Tags() { atField, ok := reflector.FindFieldByTag(field.StructField.Type, "at", tag.Key) // check if it is an array/slice @@ -335,4 +335,4 @@ func injectIntoField(field *Field) (err error) { } } return -} \ No newline at end of file +} diff --git a/pkg/inject/annotation/annotation_test.go b/pkg/inject/annotation/annotation_test.go index d676aab0..331aa972 100644 --- a/pkg/inject/annotation/annotation_test.go +++ b/pkg/inject/annotation/annotation_test.go @@ -20,7 +20,7 @@ type AtFoo struct { at.Annotation at.BaseAnnotation - AtID int `at:"fooId" json:"-"` + AtID int `at:"fooId" json:"-"` AtAge int `at:"age" json:"-"` } @@ -44,15 +44,15 @@ type AtFooBaz struct { Code int `value:"400" at:"code" json:"-"` } -type MyObj struct{ - Name string +type MyObj struct { + Name string Value string } type foo struct { - AtBaz `value:"baz"` - AtFoo `value:"foo,option 1,option 2" age:"18" fooId:"123"` - AtBar `value:"bar"` + AtBaz `value:"baz"` + AtFoo `value:"foo,option 1,option 2" age:"18" fooId:"123"` + AtBar `value:"bar"` AtFooBar `value:"foobar" age:"12"` AtFooBaz `value:"foobaz" age:"22"` MyObj @@ -66,11 +66,11 @@ type bar struct { type multipleBar struct { AtFoo `value:"foo"` AtBar `value:"bar0"` - Bar1 struct{ + Bar1 struct { AtBar `value:"bar1"` AtBaz `value:"baz"` } - Bar2 struct{ + Bar2 struct { AtBar `value:"bar2"` AtBaz `value:"baz"` } @@ -81,7 +81,7 @@ type AtIntMap struct { at.BaseAnnotation FieldName string `value:"codes"` - Codes map[int]string + Codes map[int]string } type AtStrMap struct { @@ -89,7 +89,7 @@ type AtStrMap struct { at.BaseAnnotation FieldName string `value:"messages"` - Messages map[string]string + Messages map[string]string } type foobar struct { @@ -115,7 +115,6 @@ type AtLevel3 struct { AtLevel2 } - type AtLevel4 struct { at.Annotation @@ -257,7 +256,9 @@ func TestImplementsAnnotation(t *testing.T) { }) t.Run("should inject annotation into sub struct", func(t *testing.T) { - var fb struct{at.GetMapping `value:"/path/to/api" foo:"bar"`} + var fb struct { + at.GetMapping `value:"/path/to/api" foo:"bar"` + } err := annotation.InjectAll(&fb) assert.Equal(t, nil, err) }) @@ -274,7 +275,9 @@ func TestImplementsAnnotation(t *testing.T) { }) t.Run("should get annotation by type", func(t *testing.T) { - var fb struct{at.PostMapping `value:"/path/to/api"`} + var fb struct { + at.PostMapping `value:"/path/to/api"` + } f := annotation.GetAnnotation(reflect.TypeOf(&fb), at.PostMapping{}) assert.NotEqual(t, nil, f) assert.Equal(t, "PostMapping", f.Field.StructField.Name) @@ -413,7 +416,7 @@ func TestImplementsAnnotation(t *testing.T) { at.Produces `values:"application/json"` Parameters struct { at.Parameter `name:"token" in:"header" type:"string" description:"JWT token (fake token - for demo only)" ` - Body struct { + Body struct { at.Parameter `name:"employee" in:"body" description:"Employee request body" ` foo } @@ -421,10 +424,10 @@ func TestImplementsAnnotation(t *testing.T) { Responses struct { StatusOK struct { at.Response `code:"200" description:"returns a employee with ID"` - XRateLimit struct { + XRateLimit struct { at.Header `value:"X-Rate-Limit" type:"integer" format:"int32" description:"calls per hour allowed by the user"` } - XExpiresAfter struct{ + XExpiresAfter struct { at.Header `value:"X-Expires-After" type:"string" format:"date-time" description:"date in UTC when token expires"` } bar @@ -449,4 +452,3 @@ func TestImplementsAnnotation(t *testing.T) { assert.Equal(t, 3, len(ta.AtValues)) }) } - diff --git a/pkg/inject/inject.go b/pkg/inject/inject.go index 8236c0e8..d0286d3e 100644 --- a/pkg/inject/inject.go +++ b/pkg/inject/inject.go @@ -28,7 +28,7 @@ import ( ) const ( - value = "value" + value = "value" ) var ( @@ -249,8 +249,8 @@ func (i *inject) IntoObjectValue(object reflect.Value, property string, tags ... fov := i.convert(f, injectedObject) if fov.Type().AssignableTo(fieldObjValue.Type()) { fieldObjValue.Set(fov) - //} else { - // log.Errorf("unmatched type %v against %v", fov.Type(), fieldObj.Type()) + //} else { + // log.Errorf("unmatched type %v against %v", fov.Type(), fieldObj.Type()) } } diff --git a/pkg/inject/inject_test.go b/pkg/inject/inject_test.go index 1c9f1768..6ba725fd 100644 --- a/pkg/inject/inject_test.go +++ b/pkg/inject/inject_test.go @@ -146,7 +146,7 @@ type UserService interface { type userService struct { // just put at.RequestMapping here for test only, it has no meaning - at.RequestMapping `value:"/path/to/hiboot"` + at.RequestMapping `value:"/path/to/hiboot"` FooUser *FooUser `inject:"name=foo"` User *User `inject:""` @@ -703,11 +703,11 @@ func TestInjectIntoFunc(t *testing.T) { func TestInjectAnnotation(t *testing.T) { cf := setUp(t) injecting := inject.NewInject(cf) - var att struct{ - at.GetMapping `value:"/path/to/api"` + var att struct { + at.GetMapping `value:"/path/to/api"` at.RequestMapping `value:"/parent/path"` at.BeforeMethod - Children struct{ + Children struct { at.Parameter `description:"testing params"` } } @@ -730,8 +730,8 @@ func TestInjectAnnotation(t *testing.T) { }) t.Run("should find all annotations that inherit form at.HttpMethod{}", func(t *testing.T) { - found := annotation.FindAll(&struct{at.BeforeMethod}{}, at.HttpMethod{}) + found := annotation.FindAll(&struct{ at.BeforeMethod }{}, at.HttpMethod{}) assert.Equal(t, 1, len(found)) assert.Equal(t, "BeforeMethod", found[0].Field.StructField.Name) }) -} \ No newline at end of file +} diff --git a/pkg/inject/tag.go b/pkg/inject/tag.go index fa636114..9a44e54c 100644 --- a/pkg/inject/tag.go +++ b/pkg/inject/tag.go @@ -82,4 +82,3 @@ func (t *BaseTag) Properties() cmap.ConcurrentMap { func (t *BaseTag) Decode(object reflect.Value, field reflect.StructField, property string) (retVal interface{}) { return nil } - diff --git a/pkg/model/data.go b/pkg/model/data.go index e01119a5..384d8957 100644 --- a/pkg/model/data.go +++ b/pkg/model/data.go @@ -19,11 +19,11 @@ import "time" // BaseData specifies the base data fields for database models type BaseData struct { // IsDeleted for soft delete - IsDeleted bool `json:"is_deleted,omitempty"` + IsDeleted bool `json:"is_deleted,omitempty"` // CreatedAt data created time - CreatedAt time.Time `json:"created_at,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` // UpdatedAt data updated time - UpdatedAt time.Time `json:"updated_at,omitempty"` -} \ No newline at end of file + UpdatedAt time.Time `json:"updated_at,omitempty"` +} diff --git a/pkg/model/request.go b/pkg/model/request.go index c306fe5f..6c4ee9cd 100644 --- a/pkg/model/request.go +++ b/pkg/model/request.go @@ -28,17 +28,17 @@ var ( ) // RequestBody the annotation RequestBody -type RequestBody struct{ +type RequestBody struct { at.RequestBody } // RequestForm the annotation RequestForm -type RequestForm struct{ +type RequestForm struct { at.RequestForm } // RequestParams the annotation RequestParams -type RequestParams struct{ +type RequestParams struct { at.RequestParams } @@ -50,4 +50,4 @@ type ListOptions struct { // For paginated result sets, the number of results to include per page. PerPage int `url:"per_page,omitempty" json:"per_page,omitempty" validate:"min=1"` -} \ No newline at end of file +} diff --git a/pkg/model/response.go b/pkg/model/response.go index c5de9ff1..e399f309 100644 --- a/pkg/model/response.go +++ b/pkg/model/response.go @@ -39,8 +39,8 @@ type Response interface { // BaseResponseInfo is the implementation of rest controller's Response type BaseResponseInfo struct { at.Schema - Code int `json:"code" schema:"HTTP response code"` - Message string `json:"message,omitempty" schema:"HTTP response message"` + Code int `json:"code" schema:"HTTP response code"` + Message string `json:"message,omitempty" schema:"HTTP response message"` } // SetCode set error code @@ -66,7 +66,7 @@ func (r *BaseResponseInfo) GetMessage() string { // BaseResponse is the implementation of rest controller's Response type BaseResponse struct { BaseResponseInfo - Data interface{} `json:"data,omitempty" schema:"HTTP response data"` + Data interface{} `json:"data,omitempty" schema:"HTTP response data"` } // SetData the data will be serialized to json string diff --git a/pkg/model/response_test.go b/pkg/model/response_test.go index 609128e6..fc157107 100644 --- a/pkg/model/response_test.go +++ b/pkg/model/response_test.go @@ -14,7 +14,6 @@ package model_test - import ( "github.com/stretchr/testify/assert" "hidevops.io/hiboot/pkg/model" diff --git a/pkg/starter/actuator/health.go b/pkg/starter/actuator/health.go index fb4ae3bf..90b94503 100644 --- a/pkg/starter/actuator/health.go +++ b/pkg/starter/actuator/health.go @@ -30,7 +30,7 @@ type HealthService interface { // Health is the health check struct type Health struct { at.Schema `json:"-"` - Status string `schema:"The status of health check" json:"status"` + Status string `schema:"The status of health check" json:"status"` } type healthController struct { @@ -49,11 +49,11 @@ func newHealthController(configurableFactory factory.ConfigurableFactory) *healt } // GET /health -func (c *healthController) Get( struct { +func (c *healthController) Get(struct { at.GetMapping `value:"/"` at.Operation `id:"health" description:"health check endpoint"` at.Produces `values:"application/json"` - Responses struct { + Responses struct { StatusOK struct { at.Response `code:"200" description:"Returns the status of health check"` Health diff --git a/pkg/starter/grpc/autoconfigure.go b/pkg/starter/grpc/autoconfigure.go index 83cda48b..060057a0 100644 --- a/pkg/starter/grpc/autoconfigure.go +++ b/pkg/starter/grpc/autoconfigure.go @@ -131,7 +131,6 @@ func init() { app.Register(newConfiguration, new(properties)) } - // ClientConnector is the interface that connect to grpc client // it can be injected to struct at runtime func (c *configuration) ClientConnector() ClientConnector { diff --git a/pkg/starter/httpclient/autoconfigure_test.go b/pkg/starter/httpclient/autoconfigure_test.go index 76078f12..a855bb6d 100644 --- a/pkg/starter/httpclient/autoconfigure_test.go +++ b/pkg/starter/httpclient/autoconfigure_test.go @@ -10,7 +10,7 @@ func TestConfiguration(t *testing.T) { c := newConfiguration() t.Run("should get a struct", func(t *testing.T) { - client:=c.Client() + client := c.Client() assert.IsType(t, reflect.Struct, reflect.TypeOf(client).Kind()) }) diff --git a/pkg/starter/httpclient/client_test.go b/pkg/starter/httpclient/client_test.go index efd88932..7ae3ba42 100644 --- a/pkg/starter/httpclient/client_test.go +++ b/pkg/starter/httpclient/client_test.go @@ -434,8 +434,6 @@ func TestHTTPClientGetReturnsNoErrorOn5xxFailure(t *testing.T) { require.NoError(t, err) require.Equal(t, http.StatusInternalServerError, response.StatusCode) - - } func TestHTTPClientGetReturnsErrorOnFailure(t *testing.T) { diff --git a/pkg/starter/jaeger/autoconfigure.go b/pkg/starter/jaeger/autoconfigure.go index 5d02bf37..71b69ea9 100644 --- a/pkg/starter/jaeger/autoconfigure.go +++ b/pkg/starter/jaeger/autoconfigure.go @@ -64,7 +64,7 @@ func (c *configuration) path(ctx context.Context) (path string) { //Span returns an instance of Jaeger root span. func (c *configuration) Span(ctx context.Context, tracer Tracer) (span *Span) { span = new(Span) - span.Span = tracer.StartSpan( c.path(ctx) ) + span.Span = tracer.StartSpan(c.path(ctx)) span.context = ctx return span } @@ -76,7 +76,7 @@ func (c *configuration) ChildSpan(ctx context.Context, tracer Tracer) (span *Chi span = new(ChildSpan) spanCtx, _ := tracer.Extract(opentracing.HTTPHeaders, opentracing.HTTPHeadersCarrier(ctx.Request().Header)) - span.Span = tracer.StartSpan( c.path(ctx), ext.RPCServerOption(spanCtx)) + span.Span = tracer.StartSpan(c.path(ctx), ext.RPCServerOption(spanCtx)) span.context = ctx return span } diff --git a/pkg/starter/jaeger/autoconfigure_test.go b/pkg/starter/jaeger/autoconfigure_test.go index 96e0a75b..be6fc0eb 100644 --- a/pkg/starter/jaeger/autoconfigure_test.go +++ b/pkg/starter/jaeger/autoconfigure_test.go @@ -19,7 +19,7 @@ import ( func TestConfiguration(t *testing.T) { c := newConfiguration(&properties{ - Config: config.Configuration{ + Config: config.Configuration{ ServiceName: "test", Disabled: false, RPCMetrics: false, @@ -45,8 +45,7 @@ type Controller struct { } func newController() *Controller { - return &Controller{ - } + return &Controller{} } // Get GET /foo/{foo} @@ -134,4 +133,3 @@ func TestController(t *testing.T) { Expect().Status(http.StatusOK) }) } - diff --git a/pkg/starter/jaeger/span.go b/pkg/starter/jaeger/span.go index 3064b617..e3779f08 100644 --- a/pkg/starter/jaeger/span.go +++ b/pkg/starter/jaeger/span.go @@ -19,7 +19,6 @@ type Span struct { //ChildSpan type ChildSpan Span - func (s *Span) Inject(ctx context.Context, method string, url string, req *http.Request) opentracing.Span { c := opentracing.ContextWithSpan(ctx, s) newSpan, _ := opentracing.StartSpanFromContext(c, req.RequestURI) @@ -36,7 +35,6 @@ func (s *Span) Inject(ctx context.Context, method string, url string, req *http. return newSpan } - func (s *ChildSpan) Inject(ctx context.Context, method string, url string, req *http.Request) opentracing.Span { c := opentracing.ContextWithSpan(ctx, s) newSpan, _ := opentracing.StartSpanFromContext(c, req.RequestURI) diff --git a/pkg/starter/jwt/jwtmiddleware.go b/pkg/starter/jwt/jwtmiddleware.go index 78c8fa4f..82a5602b 100644 --- a/pkg/starter/jwt/jwtmiddleware.go +++ b/pkg/starter/jwt/jwtmiddleware.go @@ -21,7 +21,7 @@ import ( "github.com/dgrijalva/jwt-go" mwjwt "github.com/iris-contrib/middleware/jwt" - ictx "github.com/kataras/iris/context" + ictx "github.com/kataras/iris/v12/context" "hidevops.io/hiboot/pkg/app/web/context" "hidevops.io/hiboot/pkg/log" ) diff --git a/pkg/starter/locale/autoconfigure.go b/pkg/starter/locale/autoconfigure.go index 466c9d11..94a87543 100644 --- a/pkg/starter/locale/autoconfigure.go +++ b/pkg/starter/locale/autoconfigure.go @@ -16,7 +16,7 @@ package locale import ( - "github.com/kataras/iris/middleware/i18n" + "github.com/kataras/iris/v12/middleware/i18n" "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/app/web/context" "hidevops.io/hiboot/pkg/utils/io" diff --git a/pkg/starter/logging/autoconfigure.go b/pkg/starter/logging/autoconfigure.go index 49e5d0dd..ae4e5648 100644 --- a/pkg/starter/logging/autoconfigure.go +++ b/pkg/starter/logging/autoconfigure.go @@ -16,7 +16,7 @@ package logging import ( - "github.com/kataras/iris/middleware/logger" + "github.com/kataras/iris/v12/middleware/logger" "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/app/web/context" ) @@ -46,7 +46,7 @@ type configuration struct { applicationContext app.ApplicationContext } -func newConfiguration(applicationContext app.ApplicationContext, properties *properties ) *configuration { +func newConfiguration(applicationContext app.ApplicationContext, properties *properties) *configuration { return &configuration{ applicationContext: applicationContext, Properties: properties, diff --git a/pkg/starter/swagger/autoconfigure.go b/pkg/starter/swagger/autoconfigure.go index 17fc0e41..5863d48d 100644 --- a/pkg/starter/swagger/autoconfigure.go +++ b/pkg/starter/swagger/autoconfigure.go @@ -1,13 +1,12 @@ package swagger - import ( "hidevops.io/hiboot/pkg/app" "hidevops.io/hiboot/pkg/at" ) const ( - // Profile is the configuration name "swagger" + // Profile is the configuration name "swagger" Profile = "swagger" ) @@ -34,6 +33,3 @@ func (c *configuration) HttpMethodSubscriber(pathsBuilder *apiPathsBuilder) *htt func (c *configuration) ApiPathsBuilder(infoBuilder *apiInfoBuilder) *apiPathsBuilder { return newApiPathsBuilder(infoBuilder) } - - - diff --git a/pkg/starter/swagger/controller.go b/pkg/starter/swagger/controller.go index 8945df42..ea2ccfc1 100644 --- a/pkg/starter/swagger/controller.go +++ b/pkg/starter/swagger/controller.go @@ -66,7 +66,9 @@ func (c *controller) serve(ctx context.Context, docsPath string) { } // UI serve static resource via context StaticResource method -func (c *controller) Swagger(at struct{ at.GetMapping `value:"/swagger.json"` }) (response string) { +func (c *controller) Swagger(at struct { + at.GetMapping `value:"/swagger.json"` +}) (response string) { b, err := c.loadDoc() if err == nil { response = string(b) @@ -75,8 +77,9 @@ func (c *controller) Swagger(at struct{ at.GetMapping `value:"/swagger.json"` }) } // UI serve static resource via context StaticResource method -func (c *controller) SwaggerUI(at struct{ at.GetMapping `value:"/swagger-ui"` }, ctx context.Context) { +func (c *controller) SwaggerUI(at struct { + at.GetMapping `value:"/swagger-ui"` +}, ctx context.Context) { c.serve(ctx, at.GetMapping.AtValue) return } - diff --git a/pkg/starter/swagger/controller_test.go b/pkg/starter/swagger/controller_test.go index bd89664a..205bd856 100644 --- a/pkg/starter/swagger/controller_test.go +++ b/pkg/starter/swagger/controller_test.go @@ -16,15 +16,15 @@ import ( ) type Asset struct { - ID int `schema:"The asset ID" json:"id" example:"1234567890"` - Name string `schema:"The asset name" json:"name" example:"John Deng"` - Amount float64 `json:"amount" example:"987654321"` - Type string `schema:"The asset type" json:"type" example:"book"` + ID int `schema:"The asset ID" json:"id" example:"1234567890"` + Name string `schema:"The asset name" json:"name" example:"John Deng"` + Amount float64 `json:"amount" example:"987654321"` + Type string `schema:"The asset type" json:"type" example:"book"` ExpirationTime time.Time `json:"expiration_time" example:"Sun Sep 29 15:47:50 CST 2019"` } type Manager struct { - ID int `schema:"The manager ID" json:"id" default:"1000000"` + ID int `schema:"The manager ID" json:"id" default:"1000000"` Name string `schema:"The manager name of the employee" json:"name" example:"John Deng"` } @@ -102,13 +102,14 @@ func (c *employeeController) BeforeMethod(at struct{ at.BeforeMethod }, ctx cont ctx.Next() return } + type Foo struct { at.Schema - Name string `json:"name"` - Child *Foo `json:"child"` - Children []*Foo `json:"children"` - GradChildren []Foo `json:"grad_children"` + Name string `json:"name"` + Child *Foo `json:"child"` + Children []*Foo `json:"children"` + GradChildren []Foo `json:"grad_children"` } // Foo @@ -140,21 +141,21 @@ func (c *employeeController) Foo(at struct { // GetEmployee func (c *employeeController) CreateEmployee(at struct { - at.PostMapping `value:"/"` - at.Operation `id:"Create Employee" description:"This is the employee creation api"` - at.Consumes `values:"application/json"` - at.Produces `values:"application/json"` - at.Tags `values:"create,employee,new"` + at.PostMapping `value:"/"` + at.Operation `id:"Create Employee" description:"This is the employee creation api"` + at.Consumes `values:"application/json"` + at.Produces `values:"application/json"` + at.Tags `values:"create,employee,new"` at.ExternalDocs `url:"http://hiboot.hidevops.io" description:"HiBoot Official Site"` - Parameters struct { + Parameters struct { at.Parameter `name:"employee" in:"body" description:"Employee request body" ` CreateEmployeeRequest } Responses struct { StatusOK struct { at.Response `code:"200" description:"returns a employee with ID"` - Headers struct{ - XRateLimit struct{ + Headers struct { + XRateLimit struct { at.Header `value:"X-Rate-Limit" type:"integer" format:"int32" description:"calls per hour allowed by the user"` } XExpiresAfter struct { @@ -264,7 +265,6 @@ func (c *employeeController) GetEmployeeName(at struct { return "Donald Trump" } - // ListEmployee func (c *employeeController) ListEmployee(at struct { at.GetMapping `value:"/"` @@ -414,14 +414,11 @@ limitations under the License. Expect().Status(http.StatusOK) }) - t.Run("should get employee ", func(t *testing.T) { testApp.Get("/employee/123/name"). Expect().Status(http.StatusOK) }) - - t.Run("should delete employee ", func(t *testing.T) { testApp.Delete("/employee/333"). Expect().Status(http.StatusOK) diff --git a/pkg/starter/swagger/doc.go b/pkg/starter/swagger/doc.go index 2b8fe7c3..21c3f42d 100644 --- a/pkg/starter/swagger/doc.go +++ b/pkg/starter/swagger/doc.go @@ -30,4 +30,4 @@ func init() { ) } -*/ \ No newline at end of file +*/ diff --git a/pkg/starter/swagger/info_builder.go b/pkg/starter/swagger/info_builder.go index f0b36b3a..b8574fdd 100644 --- a/pkg/starter/swagger/info_builder.go +++ b/pkg/starter/swagger/info_builder.go @@ -106,7 +106,6 @@ func (b *apiInfoBuilder) Schemes(values ...string) ApiInfoBuilderInterface { return b } - func (b *apiInfoBuilder) ContactName(value string) ApiInfoBuilderInterface { b.ensureContact() b.Swagger.SwaggerProps.Info.Contact.Name = value diff --git a/pkg/starter/swagger/paths_builder.go b/pkg/starter/swagger/paths_builder.go index 81768577..0da09d1e 100644 --- a/pkg/starter/swagger/paths_builder.go +++ b/pkg/starter/swagger/paths_builder.go @@ -46,23 +46,23 @@ func newApiPathsBuilder(builder *apiInfoBuilder) *apiPathsBuilder { apiInfoBuilder: builder, primitiveTypes: map[string]string{ // array, boolean, integer, number, object, string - "string": "string", - "int": "integer", - "int8": "integer", - "int16": "integer", - "int32": "integer", - "int64": "integer", - "uint": "integer", - "uint8": "integer", - "uint16": "integer", - "uint32": "integer", - "uint64": "integer", + "string": "string", + "int": "integer", + "int8": "integer", + "int16": "integer", + "int32": "integer", + "int64": "integer", + "uint": "integer", + "uint8": "integer", + "uint16": "integer", + "uint32": "integer", + "uint64": "integer", "float32": "number", "float64": "number", - "struct": "object", - "slice": "array", - "bool": "boolean", - "Time": "string", + "struct": "object", + "slice": "array", + "bool": "boolean", + "Time": "string", }, } } @@ -79,7 +79,7 @@ func deepFields(reflectType reflect.Type) []reflect.StructField { } if v.Anonymous { - vk := reflector.IndirectType(v.Type).Kind() + vk := reflector.IndirectType(v.Type).Kind() if vk == reflect.Struct || vk == reflect.Interface { fields = append(fields, deepFields(v.Type)...) } @@ -92,7 +92,7 @@ func deepFields(reflectType reflect.Type) []reflect.StructField { return fields } -func (b *apiPathsBuilder) buildSchemaArray(definition *spec.Schema, typ reflect.Type, recursive bool) { +func (b *apiPathsBuilder) buildSchemaArray(definition *spec.Schema, typ reflect.Type, recursive bool) { definition.Type = spec.StringOrArray{"array"} // array items arrSchema := spec.Schema{} @@ -101,7 +101,7 @@ func (b *apiPathsBuilder) buildSchemaArray(definition *spec.Schema, typ reflect. definition.Items = &spec.SchemaOrArray{Schema: &arrSchema} } -func (b *apiPathsBuilder) buildSchemaProperty(definition *spec.Schema, typ reflect.Type, recursive bool) { +func (b *apiPathsBuilder) buildSchemaProperty(definition *spec.Schema, typ reflect.Type, recursive bool) { kind := typ.Kind() if kind == reflect.Slice { @@ -336,7 +336,7 @@ func (b *apiPathsBuilder) buildResponse(operation *spec.Operation, annotations * return } -func (b *apiPathsBuilder) buildOperation(operation *spec.Operation, annotations *annotation.Annotations) { +func (b *apiPathsBuilder) buildOperation(operation *spec.Operation, annotations *annotation.Annotations) { for _, a := range annotations.Items { ao := a.Field.Value.Interface() switch ao.(type) { @@ -385,7 +385,7 @@ func (b *apiPathsBuilder) Build(atController *annotation.Annotations, atMethod * pathItem := b.apiInfoBuilder.Paths.Paths[path] - ann := annotation.GetAnnotation(atMethod, at.Operation{}) + ann := annotation.GetAnnotation(atMethod, at.Operation{}) atOperationInterface := ann.Field.Value.Interface() atOperation := atOperationInterface.(at.Operation) diff --git a/pkg/starter/websocket/properties.go b/pkg/starter/websocket/properties.go index 9785ce3e..d33872ec 100644 --- a/pkg/starter/websocket/properties.go +++ b/pkg/starter/websocket/properties.go @@ -13,24 +13,24 @@ type properties struct { // If empty then defaults to []byte("websocket:"). EvtMessagePrefix string `default:"websocket:"` // HandshakeTimeout specifies the duration for the handshake to complete. - HandshakeTimeout int64 `default:"0"` + HandshakeTimeout int64 `default:"0"` // WriteTimeout time allowed to write a message to the connection. // 0 means no timeout. // Default value is 0 - WriteTimeout int64 `default:"0"` + WriteTimeout int64 `default:"0"` // ReadTimeout time allowed to read a message from the connection. // 0 means no timeout. // Default value is 0 - ReadTimeout int64 `default:"0"` + ReadTimeout int64 `default:"0"` // PongTimeout allowed to read the next pong message from the connection. // Default value is 60 * time.Second - PongTimeout int64 `default:"60"` + PongTimeout int64 `default:"60"` // PingPeriod send ping messages to the connection within this period. Must be less than PongTimeout. // Default value is 60 *time.Second - PingPeriod int64 `default:"60"` + PingPeriod int64 `default:"60"` // MaxMessageSize max message size allowed from connection. // Default value is 1024 - MaxMessageSize int64 `default:"1024"` + MaxMessageSize int64 `default:"1024"` // BinaryMessages set it to true in order to denotes binary data messages instead of utf-8 text // compatible if you wanna use the Connection's EmitMessage to send a custom binary data to the client, like a native server-client communication. // Default value is false diff --git a/pkg/starter/websocket/ws/client.go b/pkg/starter/websocket/ws/client.go index 2144411a..5718cbd9 100644 --- a/pkg/starter/websocket/ws/client.go +++ b/pkg/starter/websocket/ws/client.go @@ -3,7 +3,7 @@ package websocket import ( "time" - "github.com/kataras/iris/context" + "github.com/kataras/iris/v12/context" ) // ClientHandler is the handler which serves the javascript client-side diff --git a/pkg/starter/websocket/ws/config.go b/pkg/starter/websocket/ws/config.go index 7eaf8f4b..36a9e7c1 100644 --- a/pkg/starter/websocket/ws/config.go +++ b/pkg/starter/websocket/ws/config.go @@ -5,7 +5,7 @@ import ( "net/http" "time" - "github.com/kataras/iris/context" + "github.com/kataras/iris/v12/context" "github.com/iris-contrib/go.uuid" ) diff --git a/pkg/starter/websocket/ws/connection.go b/pkg/starter/websocket/ws/connection.go index 4ceb1084..b7c61434 100644 --- a/pkg/starter/websocket/ws/connection.go +++ b/pkg/starter/websocket/ws/connection.go @@ -10,7 +10,7 @@ import ( "time" "github.com/gorilla/websocket" - "github.com/kataras/iris/context" + "github.com/kataras/iris/v12/context" ) type ( diff --git a/pkg/starter/websocket/ws/message.go b/pkg/starter/websocket/ws/message.go index 804baa3c..247a88b8 100644 --- a/pkg/starter/websocket/ws/message.go +++ b/pkg/starter/websocket/ws/message.go @@ -4,9 +4,9 @@ import ( "bytes" "encoding/binary" "encoding/json" + "fmt" "strconv" - "github.com/kataras/iris/core/errors" "github.com/valyala/bytebufferpool" ) @@ -127,7 +127,7 @@ func (ms *messageSerializer) serialize(event string, data interface{}) ([]byte, return message, nil } -var errInvalidTypeMessage = errors.New("Type %s is invalid for message: %s") +var errInvalidTypeMessage = fmt.Errorf("invalid message type") // deserialize deserializes a custom websocket message from the client // ex: iris-websocket-message;chat;4;themarshaledstringfromajsonstruct will return 'hello' as string @@ -135,7 +135,7 @@ var errInvalidTypeMessage = errors.New("Type %s is invalid for message: %s") func (ms *messageSerializer) deserialize(event []byte, websocketMessage []byte) (interface{}, error) { dataStartIdx := ms.prefixAndSepIdx + len(event) + 3 if len(websocketMessage) <= dataStartIdx { - return nil, errors.New("websocket invalid message: " + string(websocketMessage)) + return nil, fmt.Errorf("websocket invalid message: %s", string(websocketMessage)) } typ, err := strconv.Atoi(string(websocketMessage[ms.prefixAndSepIdx+len(event)+1 : ms.prefixAndSepIdx+len(event)+2])) // in order to iris-websocket-message;user;-> 4 @@ -166,7 +166,7 @@ func (ms *messageSerializer) deserialize(event []byte, websocketMessage []byte) err := json.Unmarshal(data, &msg) return msg, err default: - return nil, errInvalidTypeMessage.Format(messageType(typ).Name(), websocketMessage) + return nil, fmt.Errorf("message: %v of type: %s", websocketMessage, messageType(typ).Name()) } } diff --git a/pkg/starter/websocket/ws/server.go b/pkg/starter/websocket/ws/server.go index 28a25992..4dfe5dd8 100644 --- a/pkg/starter/websocket/ws/server.go +++ b/pkg/starter/websocket/ws/server.go @@ -4,7 +4,7 @@ import ( "bytes" "sync" - "github.com/kataras/iris/context" + "github.com/kataras/iris/v12/context" "github.com/gorilla/websocket" ) diff --git a/pkg/starter/websocket/ws/websocket.go b/pkg/starter/websocket/ws/websocket.go index 9cf4fdf0..140f4879 100644 --- a/pkg/starter/websocket/ws/websocket.go +++ b/pkg/starter/websocket/ws/websocket.go @@ -1,4 +1,4 @@ -/*Package websocket provides rich websocket support for the iris web framework. +/*Package websocket provides rich websocket support for the iris web framework. (Before v11.2) Source code and other details for the project are available at GitHub: diff --git a/pkg/system/builder.go b/pkg/system/builder.go index 965fa05d..2d952aca 100644 --- a/pkg/system/builder.go +++ b/pkg/system/builder.go @@ -19,7 +19,12 @@ package system import ( "bytes" "fmt" - "github.com/hidevopsio/mapstructure" + "os" + "path/filepath" + "reflect" + "strings" + + "github.com/mitchellh/mapstructure" "gopkg.in/yaml.v2" "hidevops.io/hiboot/pkg/log" "hidevops.io/hiboot/pkg/utils/io" @@ -27,10 +32,6 @@ import ( "hidevops.io/hiboot/pkg/utils/replacer" "hidevops.io/hiboot/pkg/utils/str" "hidevops.io/viper" - "os" - "path/filepath" - "reflect" - "strings" ) // Builder is the config file (yaml, json) builder @@ -38,7 +39,7 @@ type Builder interface { Init() error Build(profiles ...string) (p interface{}, err error) BuildWithProfile(profile string) (interface{}, error) - Load(properties interface{}, opts ...func (*mapstructure.DecoderConfig)) (err error) + Load(properties interface{}, opts ...func(*mapstructure.DecoderConfig)) (err error) Save(p interface{}) (err error) Replace(source string) (retVal interface{}) GetProperty(name string) (retVal interface{}) @@ -58,7 +59,7 @@ type builder struct { profiles []string } -func (b *builder) Load(properties interface{}, opts ...func (*mapstructure.DecoderConfig)) (err error) { +func (b *builder) Load(properties interface{}, opts ...func(*mapstructure.DecoderConfig)) (err error) { return } diff --git a/pkg/system/builder_test.go b/pkg/system/builder_test.go index 6caf4512..e42be379 100644 --- a/pkg/system/builder_test.go +++ b/pkg/system/builder_test.go @@ -32,7 +32,7 @@ type profiles struct { type properties struct { at.ConfigurationProperties `value:"app"` - Name string `json:"name"` + Name string `json:"name"` Profiles profiles `json:"profiles"` } @@ -48,7 +48,6 @@ func init() { var customProps = make(map[string]interface{}) - func TestBuilderBuild(t *testing.T) { err := os.Setenv("APP_NAME", "hiboot-app") diff --git a/pkg/system/properties.go b/pkg/system/properties.go index 583f6735..53593be4 100644 --- a/pkg/system/properties.go +++ b/pkg/system/properties.go @@ -83,4 +83,3 @@ type Logging struct { Level string `json:"level,omitempty" default:"info"` } - diff --git a/pkg/system/property_builder.go b/pkg/system/property_builder.go index d2b3fd59..fcd12cf6 100644 --- a/pkg/system/property_builder.go +++ b/pkg/system/property_builder.go @@ -17,7 +17,11 @@ package system import ( - "github.com/hidevopsio/mapstructure" + "os" + "path/filepath" + "strings" + + "github.com/mitchellh/mapstructure" "hidevops.io/hiboot/pkg/at" "hidevops.io/hiboot/pkg/inject/annotation" "hidevops.io/hiboot/pkg/log" @@ -26,17 +30,16 @@ import ( "hidevops.io/hiboot/pkg/utils/sort" "hidevops.io/hiboot/pkg/utils/str" "hidevops.io/viper" - "os" - "path/filepath" - "strings" ) -const ( appProfilesInclude = "app.profiles.include") +const ( + appProfilesInclude = "app.profiles.include" +) -type ConfigFile struct{ - path string - name string - fileType string +type ConfigFile struct { + path string + name string + fileType string } type propertyBuilder struct { @@ -49,7 +52,6 @@ type propertyBuilder struct { merge bool } - // NewBuilder is the constructor of system.Builder func NewPropertyBuilder(path string, customProperties map[string]interface{}) Builder { b := &propertyBuilder{ @@ -61,7 +63,6 @@ func NewPropertyBuilder(path string, customProperties map[string]interface{}) Bu return b } - // setCustomPropertiesFromArgs returns application config func (b *propertyBuilder) setCustomPropertiesFromArgs() { log.Println(os.Args) @@ -138,7 +139,7 @@ func (b *propertyBuilder) Build(profiles ...string) (conf interface{}, err error b.setCustomPropertiesFromArgs() var paths []string - configFiles := make(map[string]map[string][]string) + configFiles := make(map[string]map[string][]string) pp, _ := filepath.Abs(b.path) var profile string @@ -256,7 +257,7 @@ func (b *propertyBuilder) Build(profiles ...string) (conf interface{}, err error } // Read single file -func (b *propertyBuilder) Load(properties interface{}, opts ...func (*mapstructure.DecoderConfig)) (err error) { +func (b *propertyBuilder) Load(properties interface{}, opts ...func(*mapstructure.DecoderConfig)) (err error) { ann := annotation.GetAnnotation(properties, at.ConfigurationProperties{}) if ann != nil { prefix := ann.Field.StructField.Tag.Get("value") diff --git a/pkg/system/property_builder_test.go b/pkg/system/property_builder_test.go index 41801f94..3a260a39 100644 --- a/pkg/system/property_builder_test.go +++ b/pkg/system/property_builder_test.go @@ -35,12 +35,12 @@ var customProperties = make(map[string]interface{}) type StarProperties struct { at.ConfigurationProperties `value:"star"` - Name string `json:"name"` + Name string `json:"name"` System string `json:"system"` } func TestPropertyBuilderBuild(t *testing.T) { - os.Args = append(os.Args, "--logging.level=debug", "--foo.bar", "--foobar=foo,bar", "--foobar=foo,bar") + os.Args = append(os.Args, "--logging.level=debug", "--foo.bar", "--foobar=foo,bar", "--foobar=foo,bar") err := os.Setenv("APP_NAME", "hiboot-app") diff --git a/pkg/types/reflect.go b/pkg/types/reflect.go index a64cae1d..ebefdd27 100644 --- a/pkg/types/reflect.go +++ b/pkg/types/reflect.go @@ -4,6 +4,6 @@ import "reflect" type ReflectObject struct { Interface interface{} - Type reflect.Type - Value reflect.Value + Type reflect.Type + Value reflect.Value } diff --git a/pkg/utils/copier/copier.go b/pkg/utils/copier/copier.go index 257b59d2..e130aca2 100644 --- a/pkg/utils/copier/copier.go +++ b/pkg/utils/copier/copier.go @@ -47,7 +47,7 @@ import ( // Config configurations for Copy function type Config struct { - IgnoreEmptyValue bool + IgnoreEmptyValue bool } // IgnoreEmptyValue option to config IgnoreEmptyValue, any empty or nil value will not copy from source to destination @@ -281,7 +281,6 @@ func copyMap(dst, src map[string]interface{}, config *Config) { return } - func CopyMap(dst, src map[string]interface{}, opts ...func(*Config)) { config := &Config{} @@ -290,4 +289,4 @@ func CopyMap(dst, src map[string]interface{}, opts ...func(*Config)) { } copyMap(dst, src, config) -} \ No newline at end of file +} diff --git a/pkg/utils/copier/copier_test.go b/pkg/utils/copier/copier_test.go index 8975977b..4593a336 100644 --- a/pkg/utils/copier/copier_test.go +++ b/pkg/utils/copier/copier_test.go @@ -63,8 +63,8 @@ func TestCopier(t *testing.T) { }{ { name: "should copy struct slice", - from: &[]Bar{}, - to: &[]Foo{{Name: "foo"}, {Name: "bar"}}, + from: &[]Bar{}, + to: &[]Foo{{Name: "foo"}, {Name: "bar"}}, err: nil, }, { @@ -136,21 +136,20 @@ func TestCopier(t *testing.T) { } } - func TestCopierWithConfig(t *testing.T) { type src struct { - Str string - Int int + Str string + Int int Slice []string - Foo *Foo + Foo *Foo } type dst struct { - Str string - Int int + Str string + Int int Slice []string - Foo *Foo + Foo *Foo } type p1 struct { @@ -170,17 +169,17 @@ func TestCopierWithConfig(t *testing.T) { type baz struct { Name string } - type bar struct{ + type bar struct { Name string - Arr []baz + Arr []baz } type foo struct { Name string - Bar bar + Bar bar } type fake struct { Name string - Foo foo + Foo foo } testCases := []struct { @@ -194,58 +193,58 @@ func TestCopierWithConfig(t *testing.T) { name: "should copy struct slice deeply", from: &fake{ Name: "fake", - Foo: foo{ + Foo: foo{ Name: "foo", - Bar: bar{ + Bar: bar{ Name: "bar", }, }, }, - to: &fake{ + to: &fake{ Name: "fake", - Foo: foo{ + Foo: foo{ Name: "foo", - Bar: bar{ + Bar: bar{ Name: "bar", - Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, + Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, }, }, }, expected: &fake{ Name: "fake", - Foo: foo{ + Foo: foo{ Name: "foo", - Bar: bar{ + Bar: bar{ Name: "bar", }, }, }, - err: nil, + err: nil, }, { name: "should copy struct slice deeply", from: &fake{ Name: "fake", - Foo: foo{ + Foo: foo{ Name: "foo", - Bar: bar{ + Bar: bar{ Name: "bar", - Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, + Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, }, }, }, - to: &fake{}, + to: &fake{}, expected: &fake{ Name: "fake", - Foo: foo{ + Foo: foo{ Name: "foo", - Bar: bar{ + Bar: bar{ Name: "bar", - Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, + Arr: []baz{{Name: "foo"}, {Name: "bar"}, {Name: "baz"}}, }, }, }, - err: nil, + err: nil, }, { name: "should copy struct slice", @@ -305,7 +304,7 @@ func TestCopierWithConfig(t *testing.T) { }, { name: "Should copy from src to dst", - from: &src{Int: 1, }, + from: &src{Int: 1}, to: &dst{Str: "bar", Slice: []string{"one", "two", "three"}, Foo: &Foo{Name: "bar"}}, expected: &dst{Str: "bar", Int: 1, Slice: []string{"one", "two", "three"}, Foo: &Foo{Name: "bar"}}, err: nil, @@ -320,7 +319,6 @@ func TestCopierWithConfig(t *testing.T) { } } - type User struct { Name string Birthday *time.Time @@ -576,38 +574,38 @@ func TestScanner(t *testing.T) { func TestCopyMap(t *testing.T) { src := map[string]interface{}{ "abc": map[string]interface{}{ - "str": "string value", - "int": 123, - "int-slice": []int{1,2,3}, - "str-slice": []string{"a","b","c"}, - "str-ifc": []interface{}{"a",100,"c"}, + "str": "string value", + "int": 123, + "int-slice": []int{1, 2, 3}, + "str-slice": []string{"a", "b", "c"}, + "str-ifc": []interface{}{"a", 100, "c"}, "do-not-copy": nil, }, "opq": map[string]interface{}{ - "str": "str value", - "int": 666, - "int-slice": []int{1,2,3}, - "str-slice": []string{"j","b","c"}, - "str-ifc": []interface{}{"a",333,"c"}, + "str": "str value", + "int": 666, + "int-slice": []int{1, 2, 3}, + "str-slice": []string{"j", "b", "c"}, + "str-ifc": []interface{}{"a", 333, "c"}, }, - "def": "define", - "nil": nil, + "def": "define", + "nil": nil, "empty": "", } dst := map[string]interface{}{ "abc": map[string]interface{}{ - "str2": "hhh", - "int2": 456, - "int-slice": []int{1,2,3}, - "str-slice": []string{"j","f","k"}, - "str-ifc": []interface{}{"a",100,"c"}, - "do-not-copy": []string{"x","y"}, + "str2": "hhh", + "int2": 456, + "int-slice": []int{1, 2, 3}, + "str-slice": []string{"j", "f", "k"}, + "str-ifc": []interface{}{"a", 100, "c"}, + "do-not-copy": []string{"x", "y"}, }, - "hi": "Hi all", + "hi": "Hi all", "nil": "Nil", } copier.CopyMap(dst, src, copier.IgnoreEmptyValue) assert.Equal(t, 123, dst["abc"].(map[string]interface{})["int"]) assert.Equal(t, "define", dst["def"]) -} \ No newline at end of file +} diff --git a/pkg/utils/mapstruct/mapstruct.go b/pkg/utils/mapstruct/mapstruct.go index 60eed2d3..142c086f 100644 --- a/pkg/utils/mapstruct/mapstruct.go +++ b/pkg/utils/mapstruct/mapstruct.go @@ -18,17 +18,18 @@ package mapstruct import ( "encoding/json" "fmt" + "reflect" + "github.com/hidevopsio/mapstructure" "hidevops.io/hiboot/pkg/utils/reflector" - "reflect" ) - func WithAnnotation(config *mapstructure.DecoderConfig) { config.TagName = "at" } func WithSquash(config *mapstructure.DecoderConfig) { + // INFO: this is not part of the config structure anymore. config.Squash = true } @@ -37,7 +38,7 @@ func WithWeaklyTypedInput(config *mapstructure.DecoderConfig) { } // Decode decode (convert) map to struct -func Decode(to interface{}, from interface{}, opts ...func (*mapstructure.DecoderConfig) ) error { +func Decode(to interface{}, from interface{}, opts ...func(*mapstructure.DecoderConfig)) error { config := &mapstructure.DecoderConfig{ WeaklyTypedInput: true, Result: to, @@ -75,4 +76,4 @@ func DecodeStructToMap(val interface{}) (sm map[string]interface{}, ok bool) { } } return -} \ No newline at end of file +} diff --git a/pkg/utils/mapstruct/mapstruct_test.go b/pkg/utils/mapstruct/mapstruct_test.go index 6b374fd6..26855f0c 100644 --- a/pkg/utils/mapstruct/mapstruct_test.go +++ b/pkg/utils/mapstruct/mapstruct_test.go @@ -65,7 +65,6 @@ func TestDecode(t *testing.T) { foo := &Foo{} - err := Decode(foo, src) assert.Equal(t, nil, err) assert.Equal(t, "", foo.Name) diff --git a/pkg/utils/reflector/reflect.go b/pkg/utils/reflector/reflect.go index 5893f2e3..096d433a 100644 --- a/pkg/utils/reflector/reflect.go +++ b/pkg/utils/reflector/reflect.go @@ -71,7 +71,7 @@ func DeepFields(reflectType reflect.Type) []reflect.StructField { for i := 0; i < reflectType.NumField(); i++ { v := reflectType.Field(i) if v.Anonymous { - vk := IndirectType(v.Type).Kind() + vk := IndirectType(v.Type).Kind() if vk != reflect.Struct && vk != reflect.Interface { fields = append(fields, v) } else { @@ -124,7 +124,6 @@ func GetFieldValue(f interface{}, name string) reflect.Value { return fv } - // FindFieldByTag find field by tag func FindFieldByTag(obj interface{}, key, name string) (field reflect.StructField, ok bool) { typ, ok := GetObjectType(obj) @@ -141,7 +140,6 @@ func FindFieldByTag(obj interface{}, key, name string) (field reflect.StructFiel return } - // SetFieldValue set field value func SetFieldValue(object interface{}, name string, value interface{}) error { @@ -576,4 +574,4 @@ func Implements(object interface{}, interfaceType interface{}) (ok bool) { ok = typ.Implements(modelType) return -} \ No newline at end of file +} diff --git a/pkg/utils/reflector/reflect_test.go b/pkg/utils/reflector/reflect_test.go index 0ffe1982..16cbad23 100644 --- a/pkg/utils/reflector/reflect_test.go +++ b/pkg/utils/reflector/reflect_test.go @@ -180,7 +180,7 @@ func TestGetFieldValue(t *testing.T) { func TestFindFieldByTag(t *testing.T) { type foo struct { - Name string `json:"name"` + Name string `json:"name"` AtValues []string `at:"values"` } f := &foo{} @@ -682,7 +682,6 @@ func TestGetEmbeddedInterfaceField(t *testing.T) { EmbeddedInterfaceA EmbeddedString `value:"Hello"` EmbeddedInterfaceB - } type embeddedTypeB struct { diff --git a/pkg/utils/structtag/tags_test.go b/pkg/utils/structtag/tags_test.go index dc666486..89c42490 100644 --- a/pkg/utils/structtag/tags_test.go +++ b/pkg/utils/structtag/tags_test.go @@ -509,4 +509,4 @@ type ty struct { // require.NoError(t, err) // require.Equal(t, `bar:"baz"`, tag.Options[0]) // require.Equal(t, tagString, tags.String()) -//} \ No newline at end of file +//}