drone/internal/api/request/webhook.go
Johannes Batzill 44ec7ceb07 [Webhook] Add API and DB Basics (#142)
This change introduces:
- webhook type / store / controller / handler
- webhookExecution type / store / controller / handler
- foreign key fix for sqlite3
2022-12-28 13:07:48 -08:00

41 lines
1.1 KiB
Go

// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package request
import (
"net/http"
"github.com/harness/gitness/types"
)
const (
PathParamWebhookID = "webhook_id"
PathParamWebhookExecutionID = "webhook_execution_id"
)
func GetWebhookIDFromPath(r *http.Request) (int64, error) {
return PathParamAsInt64(r, PathParamWebhookID)
}
func GetWebhookExecutionIDFromPath(r *http.Request) (int64, error) {
return PathParamAsInt64(r, PathParamWebhookExecutionID)
}
// ParseWebhookFilter extracts the Webhook query parameters for listing from the url.
func ParseWebhookFilter(r *http.Request) *types.WebhookFilter {
return &types.WebhookFilter{
Page: ParsePage(r),
Size: ParseSize(r),
}
}
// ParseWebhookExecutionFilter extracts the WebhookExecution query parameters for listing from the url.
func ParseWebhookExecutionFilter(r *http.Request) *types.WebhookExecutionFilter {
return &types.WebhookExecutionFilter{
Page: ParsePage(r),
Size: ParseSize(r),
}
}