Skip to content

Commit

Permalink
fix: switch to query instead of path param
Browse files Browse the repository at this point in the history
  • Loading branch information
vsukhin committed Feb 12, 2024
1 parent b97161d commit 40a597a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions api/v1/testkube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ paths:
items:
$ref: "#/components/schemas/Problem"

/executors/{testType}/type:
/executor-by-types:
get:
parameters:
- $ref: "#/components/parameters/TestType"
Expand Down Expand Up @@ -6264,7 +6264,7 @@ components:
description: dont delete executions
required: false
TestType:
in: path
in: query
name: testType
schema:
type: string
Expand Down
7 changes: 3 additions & 4 deletions internal/app/api/v1/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"fmt"
"net/http"
"net/url"

"github.com/gofiber/fiber/v2"
"k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -202,9 +201,9 @@ func (s TestkubeAPI) GetExecutorByTestTypeHandler() fiber.Handler {
return func(c *fiber.Ctx) error {
errPrefix := "failed to get executor by test type"

testType, err := url.PathUnescape(c.Params("testType"))
if err != nil {
return s.Error(c, http.StatusBadRequest, fmt.Errorf("%s: could not parse test type: %w", errPrefix, err))
testType := c.Query("testType", "")
if testType == "" {
return s.Error(c, http.StatusBadRequest, fmt.Errorf("%s: could not fine test type", errPrefix))
}

item, err := s.ExecutorsClient.GetByType(testType)
Expand Down
4 changes: 3 additions & 1 deletion internal/app/api/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,13 @@ func (s *TestkubeAPI) InitRoutes() {
executors.Post("/", s.CreateExecutorHandler())
executors.Get("/", s.ListExecutorsHandler())
executors.Get("/:name", s.GetExecutorHandler())
executors.Get("/:testType/type", s.GetExecutorByTestTypeHandler())
executors.Patch("/:name", s.UpdateExecutorHandler())
executors.Delete("/:name", s.DeleteExecutorHandler())
executors.Delete("/", s.DeleteExecutorsHandler())

executorByTypes := root.Group("/executor-by-types")
executorByTypes.Get("/", s.GetExecutorByTestTypeHandler())

webhooks := root.Group("/webhooks")

webhooks.Post("/", s.CreateWebhookHandler())
Expand Down

0 comments on commit 40a597a

Please sign in to comment.