Refactor proto into single package and update api
This commit is contained in:
@@ -4,8 +4,8 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
get_runnerv1 "git.ohea.xyz/cursorius/server/proto/gen/get_runner/v1"
|
||||
"git.ohea.xyz/cursorius/server/proto/gen/get_runner/v1/get_runnerv1connect"
|
||||
apiv1 "git.ohea.xyz/cursorius/server/proto/gen/api/v1"
|
||||
"git.ohea.xyz/cursorius/server/proto/gen/api/v1/apiv1connect"
|
||||
"github.com/bufbuild/connect-go"
|
||||
"github.com/op/go-logging"
|
||||
)
|
||||
@@ -16,18 +16,34 @@ type ApiServer struct{}
|
||||
|
||||
func (s *ApiServer) GetRunner(
|
||||
ctx context.Context,
|
||||
req *connect.Request[get_runnerv1.GetRunnerRequest],
|
||||
) (*connect.Response[get_runnerv1.GetRunnerResponse], error) {
|
||||
req *connect.Request[apiv1.GetRunnerRequest],
|
||||
) (*connect.Response[apiv1.GetRunnerResponse], error) {
|
||||
|
||||
res := connect.NewResponse(&get_runnerv1.GetRunnerResponse{
|
||||
res := connect.NewResponse(&apiv1.GetRunnerResponse{
|
||||
RunnerId: 0,
|
||||
})
|
||||
res.Header().Set("GetRunner-Version", "v1")
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (s *ApiServer) RunCommand(
|
||||
ctx context.Context,
|
||||
req *connect.Request[apiv1.RunCommandRequest],
|
||||
) (*connect.Response[apiv1.RunCommandResponse], error) {
|
||||
|
||||
res := connect.NewResponse(&apiv1.RunCommandResponse{
|
||||
ReturnCode: 0,
|
||||
Stdout: "",
|
||||
Stderr: "",
|
||||
})
|
||||
res.Header().Set("RunCommand-Version", "v1")
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func CreateHandler(mux *http.ServeMux) {
|
||||
api_server := &ApiServer{}
|
||||
path, handler := get_runnerv1connect.NewGetRunnerServiceHandler(api_server)
|
||||
path, handler := apiv1connect.NewGetRunnerServiceHandler(api_server)
|
||||
mux.Handle(path, handler)
|
||||
path, handler = apiv1connect.NewRunCommandServiceHandler(api_server)
|
||||
mux.Handle(path, handler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user