http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: AGPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package http provides primitives to interact with the openapi HTTP API.

Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.6.0 DO NOT EDIT.

Index

Constants

View Source
const (
	BearerAuthScopes = "BearerAuth.Scopes"
	TokenAuthScopes  = "TokenAuth.Scopes"
)

Variables

This section is empty.

Functions

func GetSwagger

func GetSwagger() (swagger *openapi3.T, err error)

GetSwagger returns the Swagger specification corresponding to the generated code in this file. The external references of Swagger specification are resolved. The logic of resolving external references is tightly connected to "import-mapping" feature. Externally referenced files must be embedded in the corresponding golang packages. Urls can be supported but this task was out of the scope.

func PathToRawSpec

func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error)

Constructs a synthetic filesystem for resolving external references when loading openapi specifications.

func RegisterHandlers

func RegisterHandlers(router EchoRouter, si ServerInterface)

RegisterHandlers adds each server route to the EchoRouter.

func RegisterHandlersWithBaseURL

func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)

Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.

Types

type ActionFilter

type ActionFilter = string

ActionFilter defines model for action_filter.

type Actor

type Actor struct {
	ActorType string                  `json:"actor_type"`
	Id        string                  `json:"id"`
	Metadata  *map[string]interface{} `json:"metadata,omitempty"`
	Name      *string                 `json:"name,omitempty"`
}

Actor defines model for Actor.

type BadRequestError

type BadRequestError = ErrorSchema

BadRequestError defines model for BadRequestError.

type Config

type Config struct {
	Application       *app.App
	Port              int
	AllowedCorsOrigin []string
	Logger            *logs.Logger
	IsDebug           bool
	Context           context.Context
	JwtPublicKey      *ecdsa.PublicKey
}

type Context

type Context struct {
	Location  string  `json:"location"`
	UserAgent *string `json:"user_agent,omitempty"`
}

Context defines model for Context.

type CreateEventJSONBody

type CreateEventJSONBody struct {
	// Action Event type action
	Action string `json:"action"`
	Actor  struct {
		Id       string                  `json:"id"`
		Metadata *map[string]interface{} `json:"metadata,omitempty"`
		Name     *string                 `json:"name,omitempty"`
		Type     string                  `json:"type"`
	} `json:"actor"`
	Context struct {
		Location  string  `json:"location"`
		UserAgent *string `json:"user_agent,omitempty"`
	} `json:"context"`
	Metadata   *map[string]interface{} `json:"metadata,omitempty"`
	OccurredAt time.Time               `json:"occurred_at"`
	SourceId   string                  `json:"source_id"`
	Targets    []struct {
		Id       string                  `json:"id"`
		Metadata *map[string]interface{} `json:"metadata,omitempty"`
		Name     *string                 `json:"name,omitempty"`
		Type     string                  `json:"type"`
	} `json:"targets"`
	Version int `json:"version"`
}

CreateEventJSONBody defines parameters for CreateEvent.

type CreateEventJSONRequestBody

type CreateEventJSONRequestBody CreateEventJSONBody

CreateEventJSONRequestBody defines body for CreateEvent for application/json ContentType.

type CreateEventParams

type CreateEventParams struct {
	XToken XToken `json:"x-token"`
}

CreateEventParams defines parameters for CreateEvent.

type CreateEventTypeJSONBody

type CreateEventTypeJSONBody struct {
	Action                       string   `json:"action"`
	Schema                       *string  `json:"schema,omitempty"`
	ShouldValidateMetadataSchema bool     `json:"should_validate_metadata_schema"`
	TargetTypes                  []string `json:"target_types"`
}

CreateEventTypeJSONBody defines parameters for CreateEventType.

type CreateEventTypeJSONRequestBody

type CreateEventTypeJSONRequestBody CreateEventTypeJSONBody

CreateEventTypeJSONRequestBody defines body for CreateEventType for application/json ContentType.

type CreateEventTypeVersionJSONBody

type CreateEventTypeVersionJSONBody struct {
	Schema      *string  `json:"schema,omitempty"`
	TargetTypes []string `json:"target_types"`
}

CreateEventTypeVersionJSONBody defines parameters for CreateEventTypeVersion.

type CreateEventTypeVersionJSONRequestBody

type CreateEventTypeVersionJSONRequestBody CreateEventTypeVersionJSONBody

CreateEventTypeVersionJSONRequestBody defines body for CreateEventTypeVersion for application/json ContentType.

type CreateSourceJSONBody

type CreateSourceJSONBody struct {
	Name string `json:"name"`
}

CreateSourceJSONBody defines parameters for CreateSource.

type CreateSourceJSONRequestBody

type CreateSourceJSONRequestBody CreateSourceJSONBody

CreateSourceJSONRequestBody defines body for CreateSource for application/json ContentType.

type CreateTokenJSONBody

type CreateTokenJSONBody struct {
	Name string `json:"name"`
}

CreateTokenJSONBody defines parameters for CreateToken.

type CreateTokenJSONRequestBody

type CreateTokenJSONRequestBody CreateTokenJSONBody

CreateTokenJSONRequestBody defines body for CreateToken for application/json ContentType.

type EchoRouter

type EchoRouter interface {
	CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}

This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration

type ErrorSchema

type ErrorSchema struct {
	// Error Error custom error code such as 'email_in_use'
	Error string `json:"error"`

	// Message A description about the error
	Message string `json:"message"`
}

ErrorSchema defines model for ErrorSchema.

type Event

type Event struct {
	Id         string                  `json:"id"`
	SourceId   string                  `json:"source_id"`
	Action     string                  `json:"action"`
	Version    int                     `json:"version"`
	Targets    []Target                `json:"targets"`
	Metadata   *map[string]interface{} `json:"metadata,omitempty"`
	OccurredAt string                  `json:"occurred_at"`
	Actor      Actor                   `json:"actor"`
	Context    Context                 `json:"context"`
}

Event defines model for Event.

type EventId

type EventId = string

EventId defines model for event_id.

type EventList

type EventList struct {
	Data           []Event `json:"data"`
	LastItemCursor string  `json:"last_item_cursor"`
}

EventList defines model for EventList.

type EventType

type EventType struct {
	Action                       string             `json:"action"`
	Versions                     []EventTypeVersion `json:"versions"`
	ShouldValidateMetadataSchema bool               `json:"should_validate_metadata_schema"`
	CreatedAt                    time.Time          `json:"created_at"`
}

EventType defines model for EventType.

type EventTypeAction

type EventTypeAction = string

EventTypeAction defines model for event_type_action.

type EventTypeList

type EventTypeList struct {
	Data       []EventType `json:"data"`
	Pagination Pagination  `json:"pagination"`
}

EventTypeList defines model for EventTypeList.

type EventTypeVersion

type EventTypeVersion struct {
	Version     int       `json:"version"`
	TargetTypes []string  `json:"target_types"`
	Schema      *string   `json:"schema,omitempty"`
	CreatedAt   time.Time `json:"created_at"`
}

EventTypeVersion defines model for EventTypeVersion.

type EventsByActorId

type EventsByActorId = string

EventsByActorId defines model for events_by_actor_id.

type EventsByActorName

type EventsByActorName = string

EventsByActorName defines model for events_by_actor_name.

type EventsByTargetId

type EventsByTargetId = string

EventsByTargetId defines model for events_by_target_id.

type EventsEndDate

type EventsEndDate = time.Time

EventsEndDate defines model for events_end_date.

type EventsStartDate

type EventsStartDate = time.Time

EventsStartDate defines model for events_start_date.

type GetEventTypesParams

type GetEventTypesParams struct {
	// Limit The number of items per page
	Limit *PaginationLimit `form:"limit,omitempty" json:"limit,omitempty"`

	// Page The page number
	Page *PaginationPage `form:"page,omitempty" json:"page,omitempty"`

	// Action Action filter
	Action *ActionFilter `form:"action,omitempty" json:"action,omitempty"`
}

GetEventTypesParams defines parameters for GetEventTypes.

type GetEventsParams

type GetEventsParams struct {
	SourceId SourceIdQuery `form:"source_id" json:"source_id"`

	// StartFrom Opaque cursor returned by the previous page. Omit to start from the most recent event.
	StartFrom *StartFromCursor `form:"start_from,omitempty" json:"start_from,omitempty"`

	// Limit The number of items per page
	Limit     *PaginationLimit   `form:"limit,omitempty" json:"limit,omitempty"`
	ActorId   *EventsByActorId   `form:"actor_id,omitempty" json:"actor_id,omitempty"`
	ActorName *EventsByActorName `form:"actor_name,omitempty" json:"actor_name,omitempty"`
	TargetId  *EventsByTargetId  `form:"target_id,omitempty" json:"target_id,omitempty"`
	StartDate *EventsStartDate   `form:"start_date,omitempty" json:"start_date,omitempty"`
	EndDate   *EventsEndDate     `form:"end_date,omitempty" json:"end_date,omitempty"`
}

GetEventsParams defines parameters for GetEvents.

type GetSourcesParams

type GetSourcesParams struct {
	// Limit The number of items per page
	Limit *PaginationLimit `form:"limit,omitempty" json:"limit,omitempty"`

	// Page The page number
	Page *PaginationPage `form:"page,omitempty" json:"page,omitempty"`

	// Name Name filter
	Name *NameFilter `form:"name,omitempty" json:"name,omitempty"`
}

GetSourcesParams defines parameters for GetSources.

type HandlerError

type HandlerError struct {
	*echo.HTTPError
	// contains filtered or unexported fields
}

func NewBadRequestError

func NewBadRequestError(err error, slug string) *HandlerError

func NewForbiddenError

func NewForbiddenError(err error, slug string) *HandlerError

func NewHandlerError

func NewHandlerError(err error, slug string) *HandlerError

func NewHandlerErrorWithStatus

func NewHandlerErrorWithStatus(err error, slug string, code int) *HandlerError

func NewNotFoundError

func NewNotFoundError(err error, slug string) *HandlerError

func (HandlerError) Error

func (e HandlerError) Error() string

func (HandlerError) Slug

func (e HandlerError) Slug() string

type InternalServerError

type InternalServerError = ErrorSchema

InternalServerError defines model for InternalServerError.

type JWTMiddleware

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

func NewJWTMiddleware

func NewJWTMiddleware(publicKey *ecdsa.PublicKey) *JWTMiddleware

func (*JWTMiddleware) Authenticate

type LogIn

type LogIn struct {
	Jwt string `json:"jwt"`
}

LogIn defines model for LogIn.

type LogInJSONBody

type LogInJSONBody struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

LogInJSONBody defines parameters for LogIn.

type LogInJSONRequestBody

type LogInJSONRequestBody LogInJSONBody

LogInJSONRequestBody defines body for LogIn for application/json ContentType.

type NameFilter

type NameFilter = string

NameFilter defines model for name_filter.

type NotFoundError

type NotFoundError = ErrorSchema

NotFoundError defines model for NotFoundError.

type Pagination

type Pagination struct {
	Total       int `json:"total"`
	PerPage     int `json:"per_page"`
	CurrentPage int `json:"current_page"`
	TotalPages  int `json:"total_pages"`
}

Pagination defines model for Pagination.

type PaginationLimit

type PaginationLimit = int

PaginationLimit defines model for pagination_limit.

type PaginationPage

type PaginationPage = int

PaginationPage defines model for pagination_page.

type Server

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

func NewServer

func NewServer(config Config) (*Server, error)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type ServerInterface

type ServerInterface interface {
	// Create an event
	// (POST /v1/events)
	CreateEvent(ctx echo.Context, params CreateEventParams) error
	// List event types
	// (GET /x/v1/event-types)
	GetEventTypes(ctx echo.Context, params GetEventTypesParams) error
	// Create an event type
	// (POST /x/v1/event-types)
	CreateEventType(ctx echo.Context) error
	// Delete event an event type
	// (DELETE /x/v1/event-types/{event_type_action})
	DeleteEventType(ctx echo.Context, eventTypeAction EventTypeAction) error
	// Return the details of an Event Type
	// (GET /x/v1/event-types/{event_type_action})
	GetEventTypeByID(ctx echo.Context, eventTypeAction EventTypeAction) error
	// Rollback event type version
	// (DELETE /x/v1/event-types/{event_type_action}/versions)
	RollbackEventTypeVersion(ctx echo.Context, eventTypeAction EventTypeAction) error
	// Create an event type version
	// (POST /x/v1/event-types/{event_type_action}/versions)
	CreateEventTypeVersion(ctx echo.Context, eventTypeAction EventTypeAction) error
	// Get events
	// (GET /x/v1/events)
	GetEvents(ctx echo.Context, params GetEventsParams) error
	// Get event by id
	// (GET /x/v1/events/{event_id})
	GetEventByID(ctx echo.Context, eventId EventId) error
	// Log in
	// (POST /x/v1/login)
	LogIn(ctx echo.Context) error
	// Return the user details of the authenticated.
	// (GET /x/v1/profile)
	GetUserProfile(ctx echo.Context) error
	// List all sources
	// (GET /x/v1/sources)
	GetSources(ctx echo.Context, params GetSourcesParams) error
	// Create a source
	// (POST /x/v1/sources)
	CreateSource(ctx echo.Context) error
	// Get source details
	// (GET /x/v1/sources/{source_id})
	GetSourceByID(ctx echo.Context, sourceId SourceId) error
	// List tokens
	// (GET /x/v1/sources/{source_id}/tokens)
	GetTokens(ctx echo.Context, sourceId SourceId) error
	// Create token
	// (POST /x/v1/sources/{source_id}/tokens)
	CreateToken(ctx echo.Context, sourceId SourceId) error
	// Delete token
	// (DELETE /x/v1/sources/{source_id}/tokens/{token_id})
	DeleteToken(ctx echo.Context, sourceId SourceId, tokenId TokenId) error
}

ServerInterface represents all server handlers.

type ServerInterfaceWrapper

type ServerInterfaceWrapper struct {
	Handler ServerInterface
}

ServerInterfaceWrapper converts echo contexts to parameters.

func (*ServerInterfaceWrapper) CreateEvent

func (w *ServerInterfaceWrapper) CreateEvent(ctx echo.Context) error

CreateEvent converts echo context to params.

func (*ServerInterfaceWrapper) CreateEventType

func (w *ServerInterfaceWrapper) CreateEventType(ctx echo.Context) error

CreateEventType converts echo context to params.

func (*ServerInterfaceWrapper) CreateEventTypeVersion

func (w *ServerInterfaceWrapper) CreateEventTypeVersion(ctx echo.Context) error

CreateEventTypeVersion converts echo context to params.

func (*ServerInterfaceWrapper) CreateSource

func (w *ServerInterfaceWrapper) CreateSource(ctx echo.Context) error

CreateSource converts echo context to params.

func (*ServerInterfaceWrapper) CreateToken

func (w *ServerInterfaceWrapper) CreateToken(ctx echo.Context) error

CreateToken converts echo context to params.

func (*ServerInterfaceWrapper) DeleteEventType

func (w *ServerInterfaceWrapper) DeleteEventType(ctx echo.Context) error

DeleteEventType converts echo context to params.

func (*ServerInterfaceWrapper) DeleteToken

func (w *ServerInterfaceWrapper) DeleteToken(ctx echo.Context) error

DeleteToken converts echo context to params.

func (*ServerInterfaceWrapper) GetEventByID

func (w *ServerInterfaceWrapper) GetEventByID(ctx echo.Context) error

GetEventByID converts echo context to params.

func (*ServerInterfaceWrapper) GetEventTypeByID

func (w *ServerInterfaceWrapper) GetEventTypeByID(ctx echo.Context) error

GetEventTypeByID converts echo context to params.

func (*ServerInterfaceWrapper) GetEventTypes

func (w *ServerInterfaceWrapper) GetEventTypes(ctx echo.Context) error

GetEventTypes converts echo context to params.

func (*ServerInterfaceWrapper) GetEvents

func (w *ServerInterfaceWrapper) GetEvents(ctx echo.Context) error

GetEvents converts echo context to params.

func (*ServerInterfaceWrapper) GetSourceByID

func (w *ServerInterfaceWrapper) GetSourceByID(ctx echo.Context) error

GetSourceByID converts echo context to params.

func (*ServerInterfaceWrapper) GetSources

func (w *ServerInterfaceWrapper) GetSources(ctx echo.Context) error

GetSources converts echo context to params.

func (*ServerInterfaceWrapper) GetTokens

func (w *ServerInterfaceWrapper) GetTokens(ctx echo.Context) error

GetTokens converts echo context to params.

func (*ServerInterfaceWrapper) GetUserProfile

func (w *ServerInterfaceWrapper) GetUserProfile(ctx echo.Context) error

GetUserProfile converts echo context to params.

func (*ServerInterfaceWrapper) LogIn

func (w *ServerInterfaceWrapper) LogIn(ctx echo.Context) error

LogIn converts echo context to params.

func (*ServerInterfaceWrapper) RollbackEventTypeVersion

func (w *ServerInterfaceWrapper) RollbackEventTypeVersion(ctx echo.Context) error

RollbackEventTypeVersion converts echo context to params.

type Source

type Source struct {
	Id        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Source defines model for Source.

type SourceId

type SourceId = string

SourceId defines model for source_id.

type SourceIdQuery

type SourceIdQuery = string

SourceIdQuery defines model for source_id_query.

type SourceList

type SourceList struct {
	Data       []Source   `json:"data"`
	Pagination Pagination `json:"pagination"`
}

SourceList defines model for SourceList.

type StartFromCursor

type StartFromCursor = string

StartFromCursor defines model for start_from_cursor.

type Target

type Target struct {
	Id         string                  `json:"id"`
	Metadata   *map[string]interface{} `json:"metadata,omitempty"`
	Name       *string                 `json:"name,omitempty"`
	TargetType string                  `json:"target_type"`
}

Target defines model for Target.

type Token

type Token struct {
	Id        string    `json:"id"`
	Value     string    `json:"value"`
	Name      string    `json:"name"`
	SourceId  string    `json:"source_id"`
	CreatedAt time.Time `json:"created_at"`
}

Token defines model for Token.

type TokenId

type TokenId = string

TokenId defines model for token_id.

type TokenList

type TokenList struct {
	Data []Token `json:"data"`
}

TokenList defines model for TokenList.

type UnauthorizedError

type UnauthorizedError = ErrorSchema

UnauthorizedError defines model for UnauthorizedError.

type User

type User struct {
	Id    string `json:"id"`
	Email string `json:"email"`
	Role  string `json:"role"`
}

User defines model for User.

type XToken

type XToken = string

XToken defines model for x_token.

Jump to

Keyboard shortcuts

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