mirror of
https://github.com/juanfont/headscale.git
synced 2024-11-26 08:53:05 +00:00
Add an initial grpcv1 service (implementing the proto generated service)
This commit is contained in:
parent
a9da7c8fd9
commit
caa4d33cbd
1 changed files with 33 additions and 0 deletions
33
grpcv1.go
Normal file
33
grpcv1.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package headscale
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
apiV1 "github.com/juanfont/headscale/gen/go/v1"
|
||||
)
|
||||
|
||||
type headscaleV1APIServer struct { // apiV1.HeadscaleServiceServer
|
||||
apiV1.UnimplementedHeadscaleServiceServer
|
||||
h *Headscale
|
||||
}
|
||||
|
||||
func newHeadscaleV1APIServer(h *Headscale) apiV1.HeadscaleServiceServer {
|
||||
return headscaleV1APIServer{
|
||||
h: h,
|
||||
}
|
||||
}
|
||||
|
||||
func (api headscaleV1APIServer) GetMachine(
|
||||
ctx context.Context,
|
||||
request *apiV1.GetMachineRequest,
|
||||
) (*apiV1.Machine, error) {
|
||||
m, err := api.h.GetMachineByID(request.MachineId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO(kradalby): Make this function actually do something
|
||||
return &apiV1.Machine{Name: m.Name}, nil
|
||||
}
|
||||
|
||||
func (api headscaleV1APIServer) mustEmbedUnimplementedHeadscaleServiceServer() {}
|
Loading…
Reference in a new issue