Author: Paolo Lulli <paolo@lulli.net>
Remove idClient from request (only from cert CN)
server/config/config.go | 1 server/docs/docs.go | 30 +---- server/docs/swagger.json | 30 +---- server/docs/swagger.yaml | 24 +--- server/grpc/event-grpc-server.go | 4 server/grpc/grpc-tls.go | 27 +++++ server/grpc/metric-grpc-client.go | 4 server/grpc/metric-grpc-server.go | 3 server/grpc/position-grpc-server.go | 2 server/grpc/yats-grpc-server.go | 70 +++++++++++++ server/main.go | 2 server/model/models.go | 21 +++ server/proto/yats-grpc.pb.go | 159 ++++++++++++------------------ server/rest/rest-event.go | 4 server/rest/rest-metric.go | 4 server/rest/rest-position.go | 4
diff --git a/server/config/config.go b/server/config/config.go index 12227ed78f203eb48af06d6d78d1a2f97ec7321f..f355329e7975fb46c3bae7a500605f9167dace43 100644 --- a/server/config/config.go +++ b/server/config/config.go @@ -52,6 +52,7 @@ TlsActive string `json:"tlsActive"` TlsKeyFile string `json:"tlsKeyFile"` TlsCertificate string `json:"tlsCertificate"` + TlsCA string `json:"tlsCA"` LogFile string `json:"logFile"` } diff --git a/server/docs/docs.go b/server/docs/docs.go index 922c89d1bb5d8d4d58f762afbd69c6e579a72bad..c735c1ee11603508ba371fcda844ce67229da903 100644 --- a/server/docs/docs.go +++ b/server/docs/docs.go @@ -51,7 +51,7 @@ "name": "event1", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.EventModel" + "$ref": "#/definitions/model.EventRequest" } } ], @@ -181,7 +181,7 @@ "name": "metric2", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.MetricModel" + "$ref": "#/definitions/model.MetricRequest" } } ], @@ -306,7 +306,7 @@ "name": "position", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.PositionModel" + "$ref": "#/definitions/model.PositionRequest" } } ], @@ -411,15 +411,12 @@ } } }, "definitions": { - "model.EventModel": { + "model.EventRequest": { "type": "object", "properties": { "etime": { "type": "integer" }, - "id_client": { - "type": "string" - }, "name": { "type": "string" } @@ -431,9 +428,6 @@ "properties": { "from": { "type": "integer" }, - "id_client": { - "type": "string" - }, "source": { "type": "string" }, @@ -442,12 +436,9 @@ "type": "integer" } } }, - "model.MetricModel": { + "model.MetricRequest": { "type": "object", "properties": { - "id_client": { - "type": "string" - }, "mtime": { "type": "integer" }, @@ -465,9 +456,6 @@ "properties": { "from": { "type": "integer" }, - "id_client": { - "type": "string" - }, "name": { "type": "string" }, @@ -479,12 +467,9 @@ "type": "integer" } } }, - "model.PositionModel": { + "model.PositionRequest": { "type": "object", "properties": { - "id_client": { - "type": "string" - }, "lat": { "description": "TODO Check parquet types", "type": "number" @@ -506,9 +491,6 @@ "type": "object", "properties": { "from": { "type": "integer" - }, - "id_client": { - "type": "string" }, "source": { "type": "string" diff --git a/server/docs/swagger.json b/server/docs/swagger.json index 273febed9a10846f61cdf81857ee8468ba936eeb..0f327c01427f9e4d077366546dbc865dcdf847ef 100755 --- a/server/docs/swagger.json +++ b/server/docs/swagger.json @@ -44,7 +44,7 @@ "name": "event1", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.EventModel" + "$ref": "#/definitions/model.EventRequest" } } ], @@ -174,7 +174,7 @@ "name": "metric2", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.MetricModel" + "$ref": "#/definitions/model.MetricRequest" } } ], @@ -299,7 +299,7 @@ "name": "position", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/model.PositionModel" + "$ref": "#/definitions/model.PositionRequest" } } ], @@ -404,15 +404,12 @@ } } }, "definitions": { - "model.EventModel": { + "model.EventRequest": { "type": "object", "properties": { "etime": { "type": "integer" }, - "id_client": { - "type": "string" - }, "name": { "type": "string" } @@ -424,9 +421,6 @@ "properties": { "from": { "type": "integer" }, - "id_client": { - "type": "string" - }, "source": { "type": "string" }, @@ -435,12 +429,9 @@ "type": "integer" } } }, - "model.MetricModel": { + "model.MetricRequest": { "type": "object", "properties": { - "id_client": { - "type": "string" - }, "mtime": { "type": "integer" }, @@ -458,9 +449,6 @@ "properties": { "from": { "type": "integer" }, - "id_client": { - "type": "string" - }, "name": { "type": "string" }, @@ -472,12 +460,9 @@ "type": "integer" } } }, - "model.PositionModel": { + "model.PositionRequest": { "type": "object", "properties": { - "id_client": { - "type": "string" - }, "lat": { "description": "TODO Check parquet types", "type": "number" @@ -499,9 +484,6 @@ "type": "object", "properties": { "from": { "type": "integer" - }, - "id_client": { - "type": "string" }, "source": { "type": "string" diff --git a/server/docs/swagger.yaml b/server/docs/swagger.yaml index 885b323e92396c4beda14855232d0e54bf0fb772..7e5f2ffb7037f57064f3237d259ebb4b0ef3a204 100755 --- a/server/docs/swagger.yaml +++ b/server/docs/swagger.yaml @@ -1,11 +1,9 @@ basePath: / definitions: - model.EventModel: + model.EventRequest: properties: etime: type: integer - id_client: - type: string name: type: string type: object @@ -13,17 +11,13 @@ model.EventSearchRequest: properties: from: type: integer - id_client: - type: string source: type: string to: type: integer type: object - model.MetricModel: + model.MetricRequest: properties: - id_client: - type: string mtime: type: integer name: @@ -35,8 +29,6 @@ model.MetricSearchRequest: properties: from: type: integer - id_client: - type: string name: type: string source: @@ -44,10 +36,8 @@ type: string to: type: integer type: object - model.PositionModel: + model.PositionRequest: properties: - id_client: - type: string lat: description: TODO Check parquet types type: number @@ -63,8 +53,6 @@ model.PositionSearchRequest: properties: from: type: integer - id_client: - type: string source: type: string to: @@ -102,7 +90,7 @@ in: body name: event1 required: true schema: - $ref: '#/definitions/model.EventModel' + $ref: '#/definitions/model.EventRequest' produces: - application/json responses: @@ -188,7 +176,7 @@ in: body name: metric2 required: true schema: - $ref: '#/definitions/model.MetricModel' + $ref: '#/definitions/model.MetricRequest' produces: - application/json responses: @@ -271,7 +259,7 @@ in: body name: position required: true schema: - $ref: '#/definitions/model.PositionModel' + $ref: '#/definitions/model.PositionRequest' produces: - application/json responses: diff --git a/server/grpc/event-grpc-server.go b/server/grpc/event-grpc-server.go index 42f3da9696e879ad7b66b27d9877343ab1e43831..9c0775ec4df17b0f611dab993c2349e28f437165 100644 --- a/server/grpc/event-grpc-server.go +++ b/server/grpc/event-grpc-server.go @@ -19,7 +19,9 @@ ) func (s *server) CreateEvent(ctx context.Context, req *proto.CreateEventRequest) (*proto.CreateEventResponse, error) { event := req.GetEvent() - clientCN := event.IdClient + + clientCN := GetClientCN(ctx) + fmt.Printf("%s / %s ", clientCN, event.Name) db.SaveEvent(clientCN, event.Name) return &proto.CreateEventResponse{Event: event}, nil diff --git a/server/grpc/grpc-tls.go b/server/grpc/grpc-tls.go new file mode 100644 index 0000000000000000000000000000000000000000..cb9c3c89d331844976a8801adf52c73187e8fa67 --- /dev/null +++ b/server/grpc/grpc-tls.go @@ -0,0 +1,27 @@ +package grpc + +import ( + "context" + "crypto/x509" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/peer" +) + +func GetClientCN(ctx context.Context) string { + peers, ok := peer.FromContext(ctx) + if ok { + tlsInfo := peers.AuthInfo.(credentials.TLSInfo) + certificates := tlsInfo.State.PeerCertificates + //v := tlsInfo.State.VerifiedChains[0][0].Subject.CommonName + //fmt.Printf("%v - %v\n", peers.Addr.String(), v) + return extractCommonName(certificates) + } + panic("Could not extract common name") +} + +func extractCommonName(certificates []*x509.Certificate) string { + if len(certificates) > 0 { + return certificates[0].Subject.CommonName + } + panic("Could not extract common name") +} diff --git a/server/grpc/metric-grpc-client.go b/server/grpc/metric-grpc-client.go index d063ac7c0f4c93c041cd591a42b98cba7f1619eb..9fc6fdae38987416447dabdd0013f6d214545552 100644 --- a/server/grpc/metric-grpc-client.go +++ b/server/grpc/metric-grpc-client.go @@ -30,7 +30,9 @@ ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() - item := &proto.Metric{IdClient: "DefaultIdClient", Name: "Item 1", Mtime: time.Now().UnixMilli(), Value: "This is the value"} + //item := &proto.Metric{InsecureIdClient: "DefaultIdClient", Name: "Item 1", Mtime: time.Now().UnixMilli(), Value: "This is the value"} + item := &proto.Metric{Name: "Item 1", Mtime: time.Now().UnixMilli(), Value: "This is the value"} + res, err := c.CreateMetric(ctx, &proto.CreateMetricRequest{Metric: item}) if err != nil { log.Fatalf("could not create item: %v", err) diff --git a/server/grpc/metric-grpc-server.go b/server/grpc/metric-grpc-server.go index c21665d675ef7f07a93f5478a2891d3f812581a5..e696b08a49a78dd0c059e41f4d3be44e270954ed 100644 --- a/server/grpc/metric-grpc-server.go +++ b/server/grpc/metric-grpc-server.go @@ -18,8 +18,9 @@ "yats-server/proto" ) func (s *server) CreateMetric(ctx context.Context, req *proto.CreateMetricRequest) (*proto.CreateMetricResponse, error) { + clientCN := GetClientCN(ctx) metric := req.GetMetric() - clientCN := metric.IdClient + fmt.Printf("%s / %s / %s", clientCN, metric.Name, metric.Value) db.SaveMetric(clientCN, metric.Name, metric.Value) diff --git a/server/grpc/position-grpc-server.go b/server/grpc/position-grpc-server.go index 494a2d8eaa81ff3f6f0246dbd7378ac034048f5a..00d114bbc0e3f05aa52b16bfc78e1d8d06445823 100644 --- a/server/grpc/position-grpc-server.go +++ b/server/grpc/position-grpc-server.go @@ -18,8 +18,8 @@ "yats-server/proto" ) func (s *server) CreatePosition(ctx context.Context, req *proto.CreatePositionRequest) (*proto.CreatePositionResponse, error) { + clientCN := GetClientCN(ctx) position := req.GetPosition() - clientCN := position.IdClient fmt.Printf("%s / %s ", clientCN, position.Name) db.SavePosition(clientCN, position.Lat, position.Lon, position.Name) return &proto.CreatePositionResponse{Position: position}, nil diff --git a/server/grpc/yats-grpc-server.go b/server/grpc/yats-grpc-server.go index 8fed1bc63e58befd3e48034fc5172e03ebed62e2..b09fb357c0eb450669cb862ee99edcd21dded12a 100644 --- a/server/grpc/yats-grpc-server.go +++ b/server/grpc/yats-grpc-server.go @@ -11,9 +11,14 @@ package grpc import ( + "crypto/tls" + "crypto/x509" "google.golang.org/grpc" + "google.golang.org/grpc/credentials" "log" "net" + "os" + "yats-server/config" "yats-server/proto" ) @@ -21,7 +26,7 @@ type server struct { proto.UnimplementedYatsGrpcServiceServer } -func RunYatsGrpcServer(address string) { +func RunUnsecureYatsGrpcServer(address string) { lis, err := net.Listen("tcp", address) if err != nil { log.Fatalf("failed to listen: %v", err) @@ -33,3 +38,66 @@ if err := s.Serve(lis); err != nil { log.Fatalf("failed to serve: %v", err) } } + +func NOCARunSecureYatsGrpcServer(conf config.Configuration) { + + cert, err := tls.LoadX509KeyPair(conf.TlsCertificate, conf.TlsKeyFile) + + if err != nil { + log.Fatal(err) + } + opts := []grpc.ServerOption{ + grpc.Creds(credentials.NewServerTLSFromCert(&cert)), + } + + lis, err := net.Listen("tcp", conf.GrpcAddress) + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + + s := grpc.NewServer(opts...) + + proto.RegisterYatsGrpcServiceServer(s, &server{}) + log.Printf("Server is running on port %s\n", conf.GrpcAddress) + if err := s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} + +func RunSecureYatsGrpcServer(conf config.Configuration) { + caPem, err := os.ReadFile(conf.TlsCA) + if err != nil { + log.Fatal(err) + } + + certPool := x509.NewCertPool() + if !certPool.AppendCertsFromPEM(caPem) { + log.Fatal(err) + } + + serverCert, err := tls.LoadX509KeyPair(conf.TlsCertificate, conf.TlsKeyFile) + if err != nil { + log.Fatal(err) + } + + tlsconf := &tls.Config{ + Certificates: []tls.Certificate{serverCert}, + ClientAuth: tls.RequireAndVerifyClientCert, + ClientCAs: certPool, + } + + lis, err := net.Listen("tcp", conf.GrpcAddress) + if err != nil { + log.Fatalf("failed to listen: %v", err) + } + + tlsCredentials := credentials.NewTLS(tlsconf) + + s := grpc.NewServer(grpc.Creds(tlsCredentials)) + + proto.RegisterYatsGrpcServiceServer(s, &server{}) + log.Printf("Server is running on port %s\n", conf.GrpcAddress) + if err := s.Serve(lis); err != nil { + log.Fatalf("failed to serve: %v", err) + } +} diff --git a/server/main.go b/server/main.go index f3c1e011474da0e4bf09ec819ef051efefb1777f..3cef44af8e1054c066c14da115b488835db8ea8f 100644 --- a/server/main.go +++ b/server/main.go @@ -61,7 +61,7 @@ } if configuration.GrpcAddress != "" { fmt.Printf("Starting GRPC Server on address: %s\n", configuration.GrpcAddress) - go grpc.RunYatsGrpcServer(configuration.GrpcAddress) + go grpc.RunUnsecureYatsGrpcServer(configuration.GrpcAddress) } fmt.Printf("Starting REST Server on address: %s\n", configuration.RestAddress) diff --git a/server/model/models.go b/server/model/models.go index 20fa899887561a9bd028472d00521a26fa87d1e2..60caf49170bc31892e5319a83351519518a90a4a 100644 --- a/server/model/models.go +++ b/server/model/models.go @@ -17,10 +17,21 @@ Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` Value string `json:"value" parquet:"name=value, type=BYTE_ARRAY, convertedtype=UTF8"` } +type MetricRequest struct { + Mtime int64 `json:"mtime" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` + Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` + Value string `json:"value" parquet:"name=value, type=BYTE_ARRAY, convertedtype=UTF8"` +} + type EventModel struct { IdClient string `json:"id_client" parquet:"name=id_client, type=BYTE_ARRAY, convertedtype=UTF8"` Etime int64 `json:"etime" parquet:"name=etime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` +} + +type EventRequest struct { + Etime int64 `json:"etime" parquet:"name=etime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` + Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` } type PositionModel struct { @@ -31,6 +42,13 @@ Lat float64 `json:"lat" parquet:"name=lat, type=DOUBLE"` //TODO Check parquet types Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` } +type PositionRequest struct { + Ptime int64 `json:"ptime" parquet:"name=ptime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` + Lon float64 `json:"lon" parquet:"name=lon, type=DOUBLE"` //TODO Check parquet types + Lat float64 `json:"lat" parquet:"name=lat, type=DOUBLE"` //TODO Check parquet types + Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` +} + type ClientInfo struct { ID string Created int64 @@ -46,7 +64,6 @@ type MetricSearchRequest struct { From int64 `json:"from" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` To int64 `json:"to" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` - IdClient string `json:"id_client" parquet:"name=id_client, type=BYTE_ARRAY, convertedtype=UTF8"` Name string `json:"name" parquet:"name=name, type=BYTE_ARRAY, convertedtype=UTF8"` SourceApplication string `json:"source" parquet:"name=source_application, type=BYTE_ARRAY, convertedtype=UTF8"` } @@ -54,13 +71,11 @@ type EventSearchRequest struct { From int64 `json:"from" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` To int64 `json:"to" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` - IdClient string `json:"id_client" parquet:"name=id_client, type=BYTE_ARRAY, convertedtype=UTF8"` SourceApplication string `json:"source" parquet:"name=source_application, type=BYTE_ARRAY, convertedtype=UTF8"` } type PositionSearchRequest struct { From int64 `json:"from" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` To int64 `json:"to" parquet:"name=mtime, type=INT64, convertedtype=TIMESTAMP_MILLIS"` - IdClient string `json:"id_client" parquet:"name=id_client, type=BYTE_ARRAY, convertedtype=UTF8"` SourceApplication string `json:"source" parquet:"name=source_application, type=BYTE_ARRAY, convertedtype=UTF8"` } diff --git a/server/proto/yats-grpc.pb.go b/server/proto/yats-grpc.pb.go index 657ab564710cd62a3bec309201ea875b302f2182..e217f7868b3e3c2bd3b9cf1d06904f7cc4bef3a6 100644 --- a/server/proto/yats-grpc.pb.go +++ b/server/proto/yats-grpc.pb.go @@ -34,10 +34,9 @@ state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IdClient string `protobuf:"bytes,1,opt,name=id_client,json=idClient,proto3" json:"id_client,omitempty"` - Mtime int64 `protobuf:"varint,2,opt,name=mtime,proto3" json:"mtime,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` - Value string `protobuf:"bytes,4,opt,name=value,proto3" json:"value,omitempty"` + Mtime int64 `protobuf:"varint,1,opt,name=mtime,proto3" json:"mtime,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` } func (x *Metric) Reset() { @@ -72,13 +71,6 @@ func (*Metric) Descriptor() ([]byte, []int) { return file_yats_grpc_proto_rawDescGZIP(), []int{0} } -func (x *Metric) GetIdClient() string { - if x != nil { - return x.IdClient - } - return "" -} - func (x *Metric) GetMtime() int64 { if x != nil { return x.Mtime @@ -105,9 +97,8 @@ state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IdClient string `protobuf:"bytes,1,opt,name=id_client,json=idClient,proto3" json:"id_client,omitempty"` - Etime int64 `protobuf:"varint,2,opt,name=etime,proto3" json:"etime,omitempty"` - Name string `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"` + Etime int64 `protobuf:"varint,1,opt,name=etime,proto3" json:"etime,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` } func (x *Event) Reset() { @@ -142,13 +133,6 @@ func (*Event) Descriptor() ([]byte, []int) { return file_yats_grpc_proto_rawDescGZIP(), []int{1} } -func (x *Event) GetIdClient() string { - if x != nil { - return x.IdClient - } - return "" -} - func (x *Event) GetEtime() int64 { if x != nil { return x.Etime @@ -168,11 +152,10 @@ state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - IdClient string `protobuf:"bytes,1,opt,name=id_client,json=idClient,proto3" json:"id_client,omitempty"` - Ptime int64 `protobuf:"varint,2,opt,name=ptime,proto3" json:"ptime,omitempty"` - Lat float64 `protobuf:"fixed64,3,opt,name=lat,proto3" json:"lat,omitempty"` - Lon float64 `protobuf:"fixed64,4,opt,name=lon,proto3" json:"lon,omitempty"` - Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + Ptime int64 `protobuf:"varint,1,opt,name=ptime,proto3" json:"ptime,omitempty"` + Lat float64 `protobuf:"fixed64,2,opt,name=lat,proto3" json:"lat,omitempty"` + Lon float64 `protobuf:"fixed64,3,opt,name=lon,proto3" json:"lon,omitempty"` + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` } func (x *Position) Reset() { @@ -205,13 +188,6 @@ // Deprecated: Use Position.ProtoReflect.Descriptor instead. func (*Position) Descriptor() ([]byte, []int) { return file_yats_grpc_proto_rawDescGZIP(), []int{2} -} - -func (x *Position) GetIdClient() string { - if x != nil { - return x.IdClient - } - return "" } func (x *Position) GetPtime() int64 { @@ -528,67 +504,62 @@ var File_yats_grpc_proto protoreflect.FileDescriptor var file_yats_grpc_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x79, 0x61, 0x74, 0x73, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x12, 0x04, 0x79, 0x61, 0x74, 0x73, 0x22, 0x65, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x64, 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x14, - 0x0a, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x6d, - 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x4e, - 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x64, 0x5f, 0x63, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, 0x64, 0x43, 0x6c, - 0x69, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x75, - 0x0a, 0x08, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x64, - 0x5f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x69, - 0x64, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x74, 0x69, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x10, 0x0a, - 0x03, 0x6c, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6c, 0x61, 0x74, 0x12, - 0x10, 0x0a, 0x03, 0x6c, 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6c, 0x6f, - 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, - 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x06, - 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x79, - 0x61, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x22, 0x3c, 0x0a, 0x14, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x06, 0x6d, 0x65, - 0x74, 0x72, 0x69, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x79, 0x61, 0x74, - 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, - 0x22, 0x37, 0x0a, 0x12, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x45, 0x76, 0x65, - 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x13, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x21, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0b, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x15, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x08, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, - 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, - 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x44, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, - 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x50, 0x6f, 0x73, 0x69, - 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xe9, - 0x01, 0x0a, 0x0f, 0x59, 0x61, 0x74, 0x73, 0x47, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, - 0x69, 0x63, 0x12, 0x19, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, - 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, - 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x43, 0x72, 0x65, - 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x18, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, - 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, - 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, - 0x1b, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, - 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x79, - 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x27, 0x0a, 0x17, 0x63, 0x6f, - 0x6d, 0x2e, 0x6b, 0x65, 0x76, 0x77, 0x65, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x75, 0x66, 0x50, 0x01, 0x5a, 0x0a, 0x79, 0x61, 0x74, 0x73, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x12, 0x04, 0x79, 0x61, 0x74, 0x73, 0x22, 0x48, 0x0a, 0x06, 0x4d, 0x65, 0x74, 0x72, 0x69, + 0x63, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, + 0x65, 0x22, 0x31, 0x0a, 0x05, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x74, + 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x74, 0x69, 0x6d, 0x65, + 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x58, 0x0a, 0x08, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, + 0x12, 0x14, 0x0a, 0x05, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x05, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x61, 0x74, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x01, 0x52, 0x03, 0x6c, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x01, 0x52, 0x03, 0x6c, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x3b, + 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, + 0x72, 0x69, 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x22, 0x3c, 0x0a, 0x14, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, + 0x63, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x22, 0x37, 0x0a, 0x12, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x21, 0x0a, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, + 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x13, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x21, 0x0a, 0x05, 0x65, 0x76, 0x65, + 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, + 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x15, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x50, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, + 0x6e, 0x22, 0x44, 0x0a, 0x16, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, + 0x79, 0x61, 0x74, 0x73, 0x2e, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x08, 0x70, + 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x32, 0xe9, 0x01, 0x0a, 0x0f, 0x59, 0x61, 0x74, 0x73, + 0x47, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x43, + 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x12, 0x19, 0x2e, 0x79, 0x61, + 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x42, 0x0a, 0x0b, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, + 0x74, 0x12, 0x18, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, + 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x79, 0x61, + 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, + 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1b, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, + 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x43, 0x72, 0x65, + 0x61, 0x74, 0x65, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x42, 0x27, 0x0a, 0x17, 0x63, 0x6f, 0x6d, 0x2e, 0x6b, 0x65, 0x76, 0x77, 0x65, + 0x2e, 0x79, 0x61, 0x74, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x50, 0x01, + 0x5a, 0x0a, 0x79, 0x61, 0x74, 0x73, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/server/rest/rest-event.go b/server/rest/rest-event.go index 4ef1255e76742abb2d2c0d68bb7833e4d99c97aa..f6c930f9c700110dc8583c9d2ab173c0c09b060d 100644 --- a/server/rest/rest-event.go +++ b/server/rest/rest-event.go @@ -29,13 +29,13 @@ // @Schemes // @Description store events // @Tags Events // @Accept json -// @Param event1 body model.EventModel true "Event body data" +// @Param event1 body model.EventRequest true "Event body data" // @Produce json // @Success 202 {string} WriteEvent // @Router /event [post] func WriteEvent(cfg config.Configuration) gin.HandlerFunc { return func(c *gin.Context) { - var event model.EventModel + var event model.EventRequest if err := c.BindJSON(&event); err != nil { c.IndentedJSON(http.StatusBadRequest, gin.H{"ret": "-1"}) diff --git a/server/rest/rest-metric.go b/server/rest/rest-metric.go index f3e2ddc79da488506ff25395b228361b44af1eb5..0f9634459c51677db3cb0e326eae79ceaeef5a36 100644 --- a/server/rest/rest-metric.go +++ b/server/rest/rest-metric.go @@ -38,13 +38,13 @@ // @Schemes // @Description store metric // @Tags Metrics // @Accept json -// @Param metric2 body model.MetricModel true "Metric request body" +// @Param metric2 body model.MetricRequest true "Metric request body" // @Produce json // @Success 202 {string} WriteMetric // @Router /metric [post] func WriteMetric(cfg config.Configuration) gin.HandlerFunc { return func(c *gin.Context) { - var metric model.MetricModel + var metric model.MetricRequest if err := c.BindJSON(&metric); err != nil { c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-1"}) diff --git a/server/rest/rest-position.go b/server/rest/rest-position.go index 86b65c30ea90a5993ddd0e07b43684c7e20deedd..9676c9ededd40ce7aedefaec83cbc2e2f730aea2 100644 --- a/server/rest/rest-position.go +++ b/server/rest/rest-position.go @@ -19,13 +19,13 @@ // @Schemes // @Description store position // @Tags Positions // @Accept json -// @Param position body model.PositionModel true "Position body data" +// @Param position body model.PositionRequest true "Position body data" // @Produce json // @Success 202 {string} WriteEvent // @Router /position [post] func WritePosition(cfg config.Configuration) gin.HandlerFunc { return func(c *gin.Context) { - var position model.PositionModel + var position model.PositionRequest if err := c.BindJSON(&position); err != nil { c.IndentedJSON(http.StatusAccepted, gin.H{"ret": "-1"})