Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblakeley committed Mar 24, 2021
2 parents 796da58 + e0f2475 commit 23d31d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apidef/api_definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ type ValidatePathMeta struct {
ErrorResponseCode int `bson:"error_response_code" json:"error_response_code"`
}

type GoPluginMeta struct {
Path string `bson:"path" json:"path"`
Method string `bson:"method" json:"method"`
PluginPath string `bson:"plugin_path" json:"plugin_path"`
SymbolName string `bson:"func_name" json:"func_name"`
}

type ExtendedPathsSet struct {
Ignored []EndPointMeta `bson:"ignored" json:"ignored,omitempty"`
WhiteList []EndPointMeta `bson:"white_list" json:"white_list,omitempty"`
Expand Down
11 changes: 11 additions & 0 deletions gateway/api_definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ type URLSpec struct {
DoNotTrackEndpoint apidef.TrackEndpointMeta
ValidatePathMeta apidef.ValidatePathMeta
Internal apidef.InternalMeta
<<<<<<< HEAD
GoPluginMeta GoPluginMiddleware
=======
GoPluginConfig GoPluginMiddleware
>>>>>>> e0f2475caf75f4fdf97d60114b6f42df3b03f27e
IgnoreCase bool
}

Expand Down Expand Up @@ -866,6 +870,7 @@ func (a APIDefinitionLoader) compileGopluginPathspathSpec(paths []apidef.GoPlugi
// transform an extended configuration URL into an array of URLSpecs
// This way we can iterate the whole array once, on match we break with status
var urlSpec []URLSpec

for _, stringSpec := range paths {
newSpec := URLSpec{}
a.generateRegex(stringSpec.Path, &newSpec, stat)
Expand All @@ -880,6 +885,7 @@ func (a APIDefinitionLoader) compileGopluginPathspathSpec(paths []apidef.GoPlugi
fmt.Println("Cant load")
}


urlSpec = append(urlSpec, newSpec)
}

Expand Down Expand Up @@ -1242,8 +1248,13 @@ func (a *APISpec) CheckSpecMatchesStatus(r *http.Request, rxPaths []URLSpec, mod
return true, &rxPaths[i].Internal
}
case GoPlugin:
<<<<<<< HEAD
if method == rxPaths[i].GoPluginMeta.Meta.Method {
return true, &rxPaths[i].GoPluginMeta
=======
if method == rxPaths[i].Internal.Method {
return true, &rxPaths[i].GoPluginConfig
>>>>>>> e0f2475caf75f4fdf97d60114b6f42df3b03f27e
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions gateway/mw_go_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func (m *GoPluginMiddleware) Name() string {
return "GoPluginMiddleware: " + m.Path + ":" + m.SymbolName
}

func loadPerPathGoPlugins(m *GoPluginMiddleware) {
m.loadPlugin()
}

func (m *GoPluginMiddleware) EnabledForSpec() bool {

// global go plugins
Expand All @@ -104,6 +108,7 @@ func (m *GoPluginMiddleware) EnabledForSpec() bool {
return true
}
}

return false
}

Expand Down

0 comments on commit 23d31d0

Please sign in to comment.