Add a dummy get method

This commit is contained in:
2024-04-19 16:23:53 +02:00
parent 18936f7803
commit a23773d2ab
4 changed files with 66 additions and 2 deletions

View File

@ -93,7 +93,38 @@ func (e *EnvironmentsServer) Delete(ctx context.Context, in *proto.EnvironmentFu
}
func (e *EnvironmentsServer) Get(ctx context.Context, in *proto.EnvironmentId) (*proto.EnvironmentFull, error) {
return nil, nil
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
return nil, errors.New("metadata is not provided")
}
token, ok := md["token"]
if !ok {
return nil, errors.New("token is not sent via metadata")
}
uuid, ok := md["uuid"]
if !ok {
return nil, errors.New("used id is not sent via metadata")
}
environment := &controllers.Environemnt{
UserID: uuid[0],
Controller: e.controller,
Token: token[0],
}
if err := environment.Get(ctx); err != nil {
return nil, err
}
return &proto.EnvironmentFull{
Id: &proto.EnvironmentId{
Id: "test",
},
Data: &proto.EnvironmentData{
Name: environment.Data.Name,
},
}, nil
}
func (e *EnvironmentsServer) List(in *empty.Empty, stream proto.Environments_ListServer) error {