feat: os-dependent default entrypoint

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
This commit is contained in:
pancho horrillo
2020-12-23 18:44:11 +01:00
parent 0c16b5472f
commit e72c65c859
7 changed files with 23 additions and 8 deletions
+4
View File
@@ -132,6 +132,10 @@ func addRoute(res http.ResponseWriter, req *http.Request) {
return
}
if route.Entrypoint == "" {
route.Entrypoint = defaultEntrypoint
}
route.ID = id.String()
created := funcAdd(route)
+5
View File
@@ -0,0 +1,5 @@
// +build !windows
package control
var defaultEntrypoint = "/bin/sh -c"
@@ -0,0 +1,3 @@
package control
var defaultEntrypoint = "cmd.exe /c"
+3 -3
View File
@@ -19,7 +19,7 @@ package model
// Route contains the data needed to represent a Kapow! user route.
type Route struct {
// ID is the unique identifier of the Route.
ID string `json:"id"`
ID string `json:"id,omitempty"`
// Method is the HTTP method that will match this Route.
Method string `json:"method"`
@@ -33,7 +33,7 @@ type Route struct {
//
// This string will be split according to the shell parsing rules to
// be passed as a list to exec.Command.
Entrypoint string `json:"entrypoint"`
Entrypoint string `json:"entrypoint,omitempty"`
// Command is the last argument to be passed to exec.Command when
// executing the Entrypoint
@@ -43,5 +43,5 @@ type Route struct {
// It is an output field, its value is ignored as input.
Index int `json:"index"`
Debug bool `json:"debug"`
Debug bool `json:"debug,omitempty"`
}