Add prototype of pipeline api using connect

This includes refactoring of the http listener to use
a custom mux.
This commit is contained in:
2022-12-24 19:45:25 -07:00
parent 08e8104cd9
commit cd098d794d
10 changed files with 394 additions and 9 deletions
+33
View File
@@ -0,0 +1,33 @@
package pipeline_api
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"
"github.com/bufbuild/connect-go"
"github.com/op/go-logging"
)
var log = logging.MustGetLogger("cursorius-server")
type ApiServer struct{}
func (s *ApiServer) GetRunner(
ctx context.Context,
req *connect.Request[get_runnerv1.GetRunnerRequest],
) (*connect.Response[get_runnerv1.GetRunnerResponse], error) {
log.Debugf("Request Headers: %v", req.Header())
res := connect.NewResponse(&get_runnerv1.GetRunnerResponse{
Success: true,
})
res.Header().Set("GetRunner-Version", "v1")
return res, nil
}
func CreateHandler(mux *http.ServeMux) {
api_server := &ApiServer{}
path, handler := get_runnerv1connect.NewGetRunnerServiceHandler(api_server)
mux.Handle(path, handler)
}