mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
This removes split ownership for workspaces. They are now a resource of organizations and have a designated owner, which is a user. This enables simple administration for commands like: - `coder stop ben/dev` - `coder build logs colin/arch` or if we decide to allow administrators to access workspaces, they could even SSH using this syntax: `coder ssh colin/dev`.
33 lines
726 B
Go
33 lines
726 B
Go
package httpmw
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
"github.com/google/uuid"
|
|
|
|
"github.com/coder/coder/coderd/httpapi"
|
|
)
|
|
|
|
// parseUUID consumes a url parameter and parses it as a UUID.
|
|
func parseUUID(rw http.ResponseWriter, r *http.Request, param string) (uuid.UUID, bool) {
|
|
rawID := chi.URLParam(r, param)
|
|
if rawID == "" {
|
|
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
|
|
Message: fmt.Sprintf("%q must be provided", param),
|
|
})
|
|
return uuid.UUID{}, false
|
|
}
|
|
|
|
parsed, err := uuid.Parse(rawID)
|
|
if err != nil {
|
|
httpapi.Write(rw, http.StatusBadRequest, httpapi.Response{
|
|
Message: fmt.Sprintf("%q must be a uuid", param),
|
|
})
|
|
return uuid.UUID{}, false
|
|
}
|
|
|
|
return parsed, true
|
|
}
|