diff --git a/docs/docs.go b/docs/docs.go index e06c72d..824ca81 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -40,6 +40,17 @@ const docTemplate = `{ "api" ], "summary": "Return API", + "parameters": [ + { + "description": "required", + "name": "name", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "OK", diff --git a/docs/swagger.json b/docs/swagger.json index 2783363..3b5c47d 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -29,6 +29,17 @@ "api" ], "summary": "Return API", + "parameters": [ + { + "description": "required", + "name": "name", + "in": "body", + "required": true, + "schema": { + "type": "string" + } + } + ], "responses": { "200": { "description": "OK", diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 967cbac..ea12a0a 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -16,6 +16,13 @@ paths: - api post: description: Return API + parameters: + - description: required + in: body + name: name + required: true + schema: + type: string responses: "200": description: OK diff --git a/local/controller/api.go b/local/controller/api.go index 1810e45..4e0eeb3 100644 --- a/local/controller/api.go +++ b/local/controller/api.go @@ -35,7 +35,7 @@ func NewApiController(as *service.ApiService, routeGroups *common.RouteGroups) * // @Summary Return API // @Description Return API // @Tags api -// @Success 200 {array} string +// @Success 200 {array} string // @Router /v1/api [get] func (ac *ApiController) getFirst(c *fiber.Ctx) error { apiModel := ac.service.GetFirst(c) @@ -46,14 +46,23 @@ func (ac *ApiController) getFirst(c *fiber.Ctx) error { // // @Summary Return API // @Description Return API +// @Param name body string true "required" // @Tags api -// @Success 200 {array} string +// @Success 200 {array} string // @Router /v1/api [post] func (ac *ApiController) startServer(c *fiber.Ctx) error { - c.Locals("service", "ACC-Server") + model := new(Service) + if err := c.BodyParser(model); err != nil { + c.SendStatus(400) + } + c.Locals("service", model.Name) apiModel, err := ac.service.ApiStartServer(c) if err != nil { return c.SendStatus(400) } return c.SendString(apiModel) } + +type Service struct { + Name string `json:"name" xml:"name" form:"name"` +} diff --git a/local/utl/common/common.go b/local/utl/common/common.go index c7f8283..9d540ee 100644 --- a/local/utl/common/common.go +++ b/local/utl/common/common.go @@ -58,10 +58,11 @@ func Find[T any](lst *[]T, callback func(item *T) bool) *T { } func RunElevatedCommand(command string, service string) (string, error) { - cmd := exec.Command("powershell", "-File", "run_sc.ps1", command, service) + cmd := exec.Command("powershell", "-nologo", "-noprofile", "-File", "run_sc.ps1", command, service) output, err := cmd.CombinedOutput() if err != nil { - return "", fmt.Errorf("error: %v, output: %s", err, output) + log.Panic("error: %v, output: %s", err, string(output)) + return "", fmt.Errorf("error: %v, output: %s", err, string(output)) } return string(output), nil } diff --git a/local/scripts/run_sc.ps1 b/run_sc.ps1 similarity index 100% rename from local/scripts/run_sc.ps1 rename to run_sc.ps1