endpoint

package
v0.0.0-...-0be37f2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RandomEndpointLength int = 10
	DefaultLimitNumUrl   int = 1
	DefaultExpiryHours   int = 6
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckSubdomainExistsResponse

type CheckSubdomainExistsResponse struct {
	Endpoint string `json:"endpoint"`
	Exists   bool   `json:"exists"`
	Message  string `json:"message"`
}

type ContentType

type ContentType string
const (
	ApplicationJson ContentType = "application/json"
	TextYaml        ContentType = "text/yaml"
	FormUrlEncoded  ContentType = "application/x-www-form-urlencoded"
	MultipartForm   ContentType = "multipart/form-data"
)

type EgressEvent

type EgressEvent string
const (
	Hook EgressEvent = "hook"
	Err  EgressEvent = "err"
)

type EgressMessage

type EgressMessage struct {
	Type    EgressEvent     `json:"event"`
	Payload json.RawMessage `json:"payload"`
}

type Endpoint

type Endpoint struct {
	Endpoint  string    `json:"endpoint"`
	ExpiresAt time.Time `json:"expires_at"`
	Plan      string    `json:"plan"`
}

type EndpointController

type EndpointController struct {
	// contains filtered or unexported fields
}

func NewEndpointController

func NewEndpointController(service *EndpointService, wsManager *WSManager, pv *core.PasetoVerifier) *EndpointController

func (*EndpointController) Broadcast

func (ec *EndpointController) Broadcast(endpoint string, req *HookRequest)

func (*EndpointController) CheckSubdomainExistsHandler

func (ec *EndpointController) CheckSubdomainExistsHandler(c *fiber.Ctx) error

func (*EndpointController) GenerateEndpointHandler

func (ec *EndpointController) GenerateEndpointHandler(c *fiber.Ctx) error

func (*EndpointController) GetEndpointHistoryHandler

func (ec *EndpointController) GetEndpointHistoryHandler(c *fiber.Ctx) error

func (*EndpointController) GetUserEndpointsHandler

func (ec *EndpointController) GetUserEndpointsHandler(c *fiber.Ctx) error

func (*EndpointController) HookHandler

func (ec *EndpointController) HookHandler(c *fiber.Ctx) error

func (*EndpointController) InspectRequestsHandler

func (ec *EndpointController) InspectRequestsHandler(c *websocket.Conn)

func (*EndpointController) RegisterRoutes

func (ec *EndpointController) RegisterRoutes(app *fiber.App, authmw, cache fiber.Handler)

func (*EndpointController) RequestDetailsHandler

func (ec *EndpointController) RequestDetailsHandler(c *fiber.Ctx) error

func (*EndpointController) RequestDetailsUUIDHandler

func (ec *EndpointController) RequestDetailsUUIDHandler(c *fiber.Ctx) error

func (*EndpointController) StatsHandler

func (ec *EndpointController) StatsHandler(c *fiber.Ctx) error

Returns status of a given endpoint

type EndpointError

type EndpointError struct {
	Code    int
	Message string
}

func NewInternalServerError

func NewInternalServerError() *EndpointError

TODO: Convert this into checkpost custom error

func (*EndpointError) Error

func (u *EndpointError) Error() string

type EndpointExists

type EndpointExists string
const (
	Available        EndpointExists = "Its available. Sign up and make it yours"
	Taken            EndpointExists = "That endpoint is already taken. Try something else?"
	ReservedCompany  EndpointExists = "Endpoint is reserved. But, you can go ahead if you're using mail issued from that organisation."
	ReservedEndpoint EndpointExists = "Endpoint is reserved."
	BadEndpoint      EndpointExists = "Bad endpoint."
	Error            EndpointExists = "Something went wrong."
)

type EndpointQuerier

type EndpointQuerier interface {
	CheckEndpointExists(ctx context.Context, endpoint string) (bool, error)

	GetEndpointRequestCount(ctx context.Context, endpoint string) (db.GetEndpointRequestCountRow, error)
	GetEndpoint(ctx context.Context, endpoint string) (db.Endpoint, error)
	GetUserEndpoints(ctx context.Context, userId int64) ([]db.Endpoint, error)
	GetEndpointHistory(ctx context.Context, params db.GetEndpointHistoryParams) ([]db.GetEndpointHistoryRow, error)
	GetNonExpiredEndpointsOfUser(ctx context.Context, userId pgtype.Int8) ([]db.Endpoint, error)

	InsertFreeEndpoint(ctx context.Context, params db.InsertFreeEndpointParams) (db.Endpoint, error)
	InsertEndpoint(ctx context.Context, params db.InsertEndpointParams) (db.Endpoint, error)

	// TODO: Move these to requests querier
	CreateNewRequest(ctx context.Context, params db.CreateNewRequestParams) (db.Request, error)

	GetRequestById(ctx context.Context, reqId int64) (db.Request, error)
	GetRequestByUUID(ctx context.Context, uuid string) (db.Request, error)

	ExpireRequests(ctx context.Context) error
}

type EndpointService

type EndpointService struct {
	// contains filtered or unexported fields
}

func NewEndpointService

func NewEndpointService(endpointq EndpointQuerier, userq user.UserQuerier) *EndpointService

func (*EndpointService) CheckEndpointExists

func (s *EndpointService) CheckEndpointExists(ctx context.Context, subdomain string) (EndpointExists, *EndpointError)

func (*EndpointService) CreateEndpoint

func (s *EndpointService) CreateEndpoint(ctx context.Context, username string, subdomain string) (db.Endpoint, *EndpointError)

func (*EndpointService) ExpireRequests

func (s *EndpointService) ExpireRequests(ctx context.Context) error

func (*EndpointService) GetEndpointRequestHistory

func (s *EndpointService) GetEndpointRequestHistory(ctx context.Context, endpoint string, userId int64, limit int32, offset int32) ([]HookRequest, *EndpointError)

func (*EndpointService) GetEndpointStats

func (s *EndpointService) GetEndpointStats(ctx context.Context, endpoint string) (EndpointStats, *EndpointError)

func (*EndpointService) GetRequestByUUID

func (s *EndpointService) GetRequestByUUID(ctx context.Context, uuid string) (HookRequest, *EndpointError)

func (*EndpointService) GetRequestDetails

func (s *EndpointService) GetRequestDetails(ctx context.Context, reqId int64) (HookRequest, *EndpointError)

func (*EndpointService) GetUserEndpoints

func (s *EndpointService) GetUserEndpoints(ctx context.Context, userId int64) ([]Endpoint, *EndpointError)

func (*EndpointService) StoreRequestDetails

func (s *EndpointService) StoreRequestDetails(ctx context.Context, hookReq HookRequest) (db.Request, *EndpointError)

type EndpointSession

type EndpointSession struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

type EndpointStats

type EndpointStats struct {
	TotalCount   int64  `json:"total_count"`
	SuccessCount int64  `json:"success_count"`
	FailureCount int64  `json:"failure_count"`
	ExpiresAt    string `json:"expires_at"`
	Plan         string `json:"plan"`
}

type EndpointStore

type EndpointStore struct {
	// contains filtered or unexported fields
}

func NewEndpointStore

func NewEndpointStore(q db.Querier) *EndpointStore

func (EndpointStore) CheckEndpointExists

func (us EndpointStore) CheckEndpointExists(ctx context.Context, endpoint string) (bool, error)

func (EndpointStore) CreateNewRequest

func (us EndpointStore) CreateNewRequest(ctx context.Context, params db.CreateNewRequestParams) (db.Request, error)

TODO: Move this

func (EndpointStore) ExpireRequests

func (us EndpointStore) ExpireRequests(ctx context.Context) error

func (EndpointStore) GetEndpoint

func (us EndpointStore) GetEndpoint(ctx context.Context, endpoint string) (db.Endpoint, error)

func (EndpointStore) GetEndpointHistory

func (us EndpointStore) GetEndpointHistory(ctx context.Context, params db.GetEndpointHistoryParams) ([]db.GetEndpointHistoryRow, error)

func (EndpointStore) GetEndpointRequestCount

func (us EndpointStore) GetEndpointRequestCount(ctx context.Context, endpoint string) (db.GetEndpointRequestCountRow, error)

func (EndpointStore) GetNonExpiredEndpointsOfUser

func (us EndpointStore) GetNonExpiredEndpointsOfUser(ctx context.Context, userId pgtype.Int8) ([]db.Endpoint, error)

func (EndpointStore) GetRequestById

func (us EndpointStore) GetRequestById(ctx context.Context, reqId int64) (db.Request, error)

func (EndpointStore) GetRequestByUUID

func (us EndpointStore) GetRequestByUUID(ctx context.Context, uuid string) (db.Request, error)

func (EndpointStore) GetUserEndpoints

func (us EndpointStore) GetUserEndpoints(ctx context.Context, userId int64) ([]db.Endpoint, error)

func (EndpointStore) InsertEndpoint

func (us EndpointStore) InsertEndpoint(ctx context.Context, params db.InsertEndpointParams) (db.Endpoint, error)

func (EndpointStore) InsertFreeEndpoint

func (us EndpointStore) InsertFreeEndpoint(ctx context.Context, params db.InsertFreeEndpointParams) (db.Endpoint, error)

type GenerateEndpointRequest

type GenerateEndpointRequest struct {
	Endpoint string `json:"endpoint"`
}

type GenerateEndpointResponse

type GenerateEndpointResponse struct {
	Endpoint  string    `json:"endpoint"`
	ExpiresAt time.Time `json:"expires_at"`
	Plan      string    `json:"plan"`
}

type GetEndpointsHistoryResponse

type GetEndpointsHistoryResponse struct {
	Requests []HookRequest `json:"requests"`
}

type GetUserEndpointsResponse

type GetUserEndpointsResponse struct {
	Endpoints []Endpoint `json:"endpoints"`
}

type HookRequest

type HookRequest struct {
	Endpoint     string              `json:"endpoint"`
	UUID         string              `json:"uuid"`
	Path         string              `json:"path"`
	Headers      map[string][]string `json:"headers"`
	QueryParams  map[string]string   `json:"query_params"`
	FormData     map[string][]string `json:"form_data"`
	Method       string              `json:"method"`
	SourceIp     string              `json:"source_ip"`
	Content      string              `json:"content"`
	ContentType  string              `json:"content_type"`
	ContentSize  int32               `json:"content_size"`
	ResponseCode int32               `json:"response_code"`
	CreatedAt    time.Time           `json:"created_at"`
	ExpiresAt    time.Time           `json:"expires_at"`
}

type WSClient

type WSClient struct {
	// contains filtered or unexported fields
}

func NewWSClient

func NewWSClient(sessionId string, endpoint string, conn *websocket.Conn, manager *WSManager) *WSClient

type WSManager

type WSManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewWSManager

func NewWSManager() *WSManager

func (*WSManager) AddConn

func (m *WSManager) AddConn(endpoint string, conn *websocket.Conn) error

func (*WSManager) RemoveConn

func (m *WSManager) RemoveConn(endpoint string, sessionId string) error

type WSMessage

type WSMessage struct {
	Code    int             `json:"code"`
	Payload json.RawMessage `json:"payload"`
	Message string          `json:"message"`
}

Jump to

Keyboard shortcuts

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