fix: refs
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
package utils
|
||||
|
||||
// NewStringRef returns a reference to a string with given value
|
||||
func NewStringRef(v string) *string {
|
||||
return &v
|
||||
}
|
||||
|
||||
// StringValue returns the value of the given string ref
|
||||
func StringValue(r *string, defaultValue ...string) string {
|
||||
if r != nil {
|
||||
return *r
|
||||
}
|
||||
if len(defaultValue) > 0 {
|
||||
return defaultValue[0]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// NewBoolRef returns a reference to a bool with given value
|
||||
func NewBoolRef(v bool) *bool {
|
||||
return &v
|
||||
}
|
||||
|
||||
// BoolValue returns the value of the given bool ref
|
||||
func BoolValue(r *bool) bool {
|
||||
if r == nil {
|
||||
return false
|
||||
}
|
||||
return *r
|
||||
}
|
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/authorizerdev/authorizer/server/constants"
|
||||
"github.com/authorizerdev/authorizer/server/db"
|
||||
"github.com/authorizerdev/authorizer/server/db/models"
|
||||
"github.com/authorizerdev/authorizer/server/refs"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
@@ -20,7 +21,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
|
||||
return err
|
||||
}
|
||||
|
||||
if !BoolValue(webhook.Enabled) {
|
||||
if !refs.BoolValue(webhook.Enabled) {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -52,7 +53,7 @@ func RegisterEvent(ctx context.Context, eventName string, authRecipe string, use
|
||||
}
|
||||
|
||||
requestBytesBuffer := bytes.NewBuffer(requestBody)
|
||||
req, err := http.NewRequest("POST", StringValue(webhook.Endpoint), requestBytesBuffer)
|
||||
req, err := http.NewRequest("POST", refs.StringValue(webhook.Endpoint), requestBytesBuffer)
|
||||
if err != nil {
|
||||
log.Debug("error creating webhook post request: ", err)
|
||||
return err
|
||||
|
Reference in New Issue
Block a user