diff --git a/server/rest/server.go b/server/rest/server.go index ee3f29c..4384a1e 100644 --- a/server/rest/server.go +++ b/server/rest/server.go @@ -27,10 +27,11 @@ func New( listHandle workspace.ListWorkspaceQueryHandlerFunc, createHandle workspace.CreateWorkspaceCommandHandlerFunc, updateHandle workspace.UpdateWorkspaceCommandHandlerFunc, + patchHandle workspace.PatchWorkspaceCommandHandlerFunc, ) *http.Server { return &http.Server{ Addr: addr, - Handler: buildServerHandler(logger, cache, readHandle, listHandle, createHandle, updateHandle), + Handler: buildServerHandler(logger, cache, readHandle, listHandle, createHandle, updateHandle, patchHandle), ReadHeaderTimeout: 3 * time.Second, } } @@ -42,10 +43,11 @@ func buildServerHandler( listHandle workspace.ListWorkspaceQueryHandlerFunc, createHandle workspace.CreateWorkspaceCommandHandlerFunc, updateHandle workspace.UpdateWorkspaceCommandHandlerFunc, + patchHandle workspace.PatchWorkspaceCommandHandlerFunc, ) http.Handler { mux := http.NewServeMux() addHealthz(mux) - addWorkspaces(mux, cache, readHandle, listHandle, createHandle, updateHandle) + addWorkspaces(mux, cache, readHandle, listHandle, createHandle, updateHandle, patchHandle) mux.HandleFunc("GET /", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotFound) }) @@ -66,6 +68,7 @@ func addWorkspaces( listHandle workspace.ListWorkspaceQueryHandlerFunc, _ workspace.CreateWorkspaceCommandHandlerFunc, updateHandle workspace.UpdateWorkspaceCommandHandlerFunc, + patchHandle workspace.PatchWorkspaceCommandHandlerFunc, ) { // Read mux.Handle(fmt.Sprintf("GET %s/{name}", NamespacedWorkspacesPrefix), @@ -100,6 +103,16 @@ func addWorkspaces( marshal.DefaultUnmarshalerProvider, )))) + // Patch + mux.Handle(fmt.Sprintf("PATCH %s/{name}", NamespacedWorkspacesPrefix), + withAuthHeaderInfo( + withUserSignupAuth(cache, + workspace.NewPatchWorkspaceHandler( + workspace.MapPatchWorkspaceHttp, + patchHandle, + marshal.DefaultMarshalerProvider, + )))) + // Create // mux.Handle(fmt.Sprintf("POST %s", NamespacedWorkspacesPrefix), // withAuthHeaderInfo( diff --git a/server/rest/workspace/patch.go b/server/rest/workspace/patch.go index 1a79a1d..80a7407 100644 --- a/server/rest/workspace/patch.go +++ b/server/rest/workspace/patch.go @@ -47,12 +47,12 @@ func NewDefaultPatchWorkspaceHandler( // NewPatchWorkspaceHandler creates a PatchWorkspaceHandler func NewPatchWorkspaceHandler( mapperFunc PatchWorkspaceMapperFunc, - queryHandler PatchWorkspaceCommandHandlerFunc, + commandHandler PatchWorkspaceCommandHandlerFunc, marshalerProvider marshal.MarshalerProvider, ) *PatchWorkspaceHandler { return &PatchWorkspaceHandler{ MapperFunc: mapperFunc, - CommandHandler: queryHandler, + CommandHandler: commandHandler, MarshalerProvider: marshalerProvider, } }