Skip to content

Commit

Permalink
merge change for issue #224 (#245)
Browse files Browse the repository at this point in the history
* Resulve issue #224 GetRef() in support package should remove 'vendor' path

* Resulve issue #224 GetRef() in support package should remove 'vendor' path
allows trigger developer to pass request parameters to handler w/o going through output mapper

* resubmit pull request to resolve issue #224
  • Loading branch information
yxuco authored Dec 10, 2020
1 parent 7abcfcc commit 82972d8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions support/ref.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package support

import "reflect"
import (
"reflect"
"strings"
)

func GetRef(contrib interface{}) string {
v := reflect.ValueOf(contrib)
Expand All @@ -11,9 +14,18 @@ func GetRef(contrib interface{}) string {

ref := v.Type().PkgPath()

return ref
return fixPkgPathVendoring(ref)
}

type HasRef interface {
Ref() string
}

// fixes vendored paths
func fixPkgPathVendoring(pkgPath string) string {
const vendor = "/vendor/"
if i := strings.LastIndex(pkgPath, vendor); i != -1 {
return pkgPath[i+len(vendor):]
}
return pkgPath
}

0 comments on commit 82972d8

Please sign in to comment.