INNER CODE UNIT · Go

extractWebhookFromRequest

prometheus-msteams/prometheus-msteams · cmd/server/main.go:507

func extractWebhookFromRequest(request *http.Request, requestPathPrefix string) (string, error) {
	var pathAndQuery string

	// Query contains mandatory "api-version" for "worflow"
	if len(request.URL.Query()) > 0 {
		pathAndQuery = request.URL.Path + "?" + request.URL.RawQuery
	} else {
		pathAndQuery = request.URL.Path
	}

	pathAndQuery = strings.TrimPrefix(pathAndQuery, requestPathPrefix)
	if pathAndQuery != "" {
		return fmt.Sprintf("https://%s", pathAndQuery), nil
	}
	authHeader := request.Header.Get("Authorization")
	if authHeader == "" {
		return "", fmt.Errorf("neither webhook url nor bearer authorization present")
	}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…