Skip to content

Commit

Permalink
update url for switching a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
adelowo committed Jan 31, 2025
1 parent a128519 commit 4175f2c
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 178 deletions.
2 changes: 1 addition & 1 deletion server/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func buildRoutes(
r.Post("/billing",
WrapMalakHTTPHandler(logger, workspaceHandler.getBillingPortal, cfg, "workspaces.billing.portal"))

r.Post("/{reference}",
r.Post("/switch/{reference}",
WrapMalakHTTPHandler(logger, workspaceHandler.switchCurrentWorkspaceForUser, cfg, "workspaces.switch"))

r.Route("/integrations", func(r chi.Router) {
Expand Down
1 change: 1 addition & 0 deletions server/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func requireWorkspaceValidSubscription(
defer span.End()

if r.URL.Path == "/v1/workspaces/billing" ||
strings.HasPrefix(r.URL.Path, "/v1/workspaces/switch/") ||
r.URL.Path == "/v1/workspaces" ||
r.URL.Path == "/v1/user" {
next.ServeHTTP(w, r)
Expand Down
2 changes: 1 addition & 1 deletion server/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (wo *workspaceHandler) createWorkspace(
// @Failure 401 {object} APIStatus
// @Failure 404 {object} APIStatus
// @Failure 500 {object} APIStatus
// @Router /workspaces/{reference} [post]
// @Router /workspaces/switch/{reference} [post]
func (wo *workspaceHandler) switchCurrentWorkspaceForUser(
ctx context.Context,
span trace.Span,
Expand Down
112 changes: 56 additions & 56 deletions swagger/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1510,6 +1510,62 @@ const docTemplate = `{
}
}
},
"/workspaces/switch/{reference}": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"workspace"
],
"summary": "Switch current workspace",
"operationId": "switchworkspace",
"parameters": [
{
"type": "string",
"description": "Workspace unique reference.. e.g update_",
"name": "reference",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.fetchWorkspaceResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
}
}
}
},
"/workspaces/updates": {
"get": {
"consumes": [
Expand Down Expand Up @@ -2145,62 +2201,6 @@ const docTemplate = `{
}
}
}
},
"/workspaces/{reference}": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"workspace"
],
"summary": "Switch current workspace",
"operationId": "switchworkspace",
"parameters": [
{
"type": "string",
"description": "Workspace unique reference.. e.g update_",
"name": "reference",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/server.fetchWorkspaceResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"401": {
"description": "Unauthorized",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/server.APIStatus"
}
}
}
}
}
},
"definitions": {
Expand Down
144 changes: 72 additions & 72 deletions swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -3344,6 +3344,78 @@
]
}
},
"/workspaces/switch/{reference}": {
"post": {
"operationId": "switchworkspace",
"parameters": [
{
"description": "Workspace unique reference.. e.g update_",
"in": "path",
"name": "reference",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.fetchWorkspaceResponse"
}
}
},
"description": "OK"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Bad Request"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Unauthorized"
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Not Found"
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Internal Server Error"
}
},
"summary": "Switch current workspace",
"tags": [
"workspace"
]
}
},
"/workspaces/updates": {
"get": {
"parameters": [
Expand Down Expand Up @@ -4165,78 +4237,6 @@
"updates"
]
}
},
"/workspaces/{reference}": {
"post": {
"operationId": "switchworkspace",
"parameters": [
{
"description": "Workspace unique reference.. e.g update_",
"in": "path",
"name": "reference",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.fetchWorkspaceResponse"
}
}
},
"description": "OK"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Bad Request"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Unauthorized"
},
"404": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Not Found"
},
"500": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/server.APIStatus"
}
}
},
"description": "Internal Server Error"
}
},
"summary": "Switch current workspace",
"tags": [
"workspace"
]
}
}
},
"servers": [
Expand Down
Loading

0 comments on commit 4175f2c

Please sign in to comment.