mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2026-01-03 15:19:44 -06:00
Adds serverless support via the concept of webhook workers. Allows any webhook to be registered as a serverless endpoint for executing a step.
27 lines
513 B
Go
27 lines
513 B
Go
package random
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"math/big"
|
|
)
|
|
|
|
const letters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
|
|
|
// Generate generates a random string of n bytes.
|
|
func Generate(n int) (string, error) {
|
|
b := make([]byte, n)
|
|
for i := 0; i < n; i++ {
|
|
num, err := rand.Int(rand.Reader, big.NewInt(int64(len(letters))))
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
b[i] = letters[num.Int64()]
|
|
}
|
|
|
|
return string(b), nil
|
|
}
|
|
|
|
func GenerateWebhookSecret() (string, error) {
|
|
return Generate(32)
|
|
}
|