core

package
v0.0.0-...-84f279d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ForwardHttpClient = &http.Client{}
)

Functions

func SetupAdministration

func SetupAdministration(echoForWebhooks, echoForAdmin *echo.Echo, config ConfigStorage, reqStore RequestsStorage, path string)

func TransferHeaders

func TransferHeaders(dest, source http.Header)

Types

type ConfigStorage

type ConfigStorage interface {
	GetAllWebhooks() ([]*Webhook, error)
	GetWebhook(id string) (*Webhook, error)

	AddWebhook(webhook *Webhook) error
	RemoveWebhook(id string) error
	UpdateWebhook(webhook *Webhook) error
}

type ForwardUrl

type ForwardUrl struct {
	ID                     string        `bson:"_id"                     json:"id"`
	Url                    string        `bson:"url"                     json:"url"                      validate:"required"`
	KeepSuccessfulRequests int           `bson:"keepSuccessfulRequests"  json:"keepSuccessfulRequests"`
	Timeout                time.Duration `bson:"timeout"                 json:"timeout"                  validate:"required"`
	ReturnAsResponse       int           `bson:"returnAsResponse"        json:"returnAsResponse"         validate:"required"`
	WaitTillCompletion     int           `bson:"waitTillCompletion"      json:"waitForCompletion"        validate:"required"`
}

type Replay

type Replay struct {
	RequestId       string `bson:"requestId"        json:"requestId"         validate:"required"`
	WebhookId       string `bson:"webhookId"        json:"webhookId"         validate:"required"`
	ForwardUrlId    string `bson:"forwardUrlId"     json:"forwardUrlId"      validate:"required"`
	DeleteOnSuccess int    `bson:"deleteOnSuccess"  json:"deleteOnSuccess"`
}

Replay is the set of information required to replay any request. It is not stored directly in the database but as a child/nested object.

type Request

type Request struct {
	ID            string              `bson:"_id"            json:"id"`
	Method        string              `bson:"method"         json:"method"`
	Path          string              `bson:"path"           json:"path"`
	Headers       map[string][]string `bson:"headers"        json:"headers"`
	Body          string              `bson:"body"           json:"body"`
	ForwardUrl    *ForwardUrl         `bson:"forwardUrl"     json:"forwardUrl"`
	FromWebhookId string              `bson:"fromWebhookId"  json:"fromWebhookId"`
	CreatedAt     time.Time           `bson:"createdAt"      json:"createdAt"`

	ReplayPayload *Replay `bson:"replayPayload" json:"replayPayload"`
}

type RequestsStorage

type RequestsStorage interface {
	StoreRequest(request *Request) error
	GetOldestRequests(count int) ([]*Request, error)
	GetNewestRequests(count int) ([]*Request, error)
	GetRequest(id string) (*Request, error)
	DeleteRequest(id string) error
}

type Webhook

type Webhook struct {
	ID          string        `bson:"_id"          json:"id"`
	Name        string        `bson:"name"         json:"name"         validate:"required"`
	Enabled     int           `bson:"enabled"      json:"enabled"`
	Method      string        `bson:"method"       json:"method"       validate:"required"`
	Path        string        `bson:"path"         json:"path"         validate:"required"`
	ForwardUrls []*ForwardUrl `bson:"forwardUrls"  json:"forwardUrls"  validate:"required"`

	CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
}

func (*Webhook) RegisterWithEcho

func (w *Webhook) RegisterWithEcho(e *echo.Echo, storage RequestsStorage) error

func (*Webhook) Verify

func (w *Webhook) Verify() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL