web

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFiberConfig

func GetFiberConfig() fiber.Config

func GetFiberLogger

func GetFiberLogger() logger.Config

func GetJWTClaim

func GetJWTClaim(c *fiber.Ctx, key string) (interface{}, error)

func GetPayload

func GetPayload(c *fiber.Ctx, payload interface{}) *apierror.APIError

func JWTPostValidate

func JWTPostValidate(c *fiber.Ctx) error

func JWTProtected

func JWTProtected() func(*fiber.Ctx) error

func RateLimiterAccounts

func RateLimiterAccounts(rateLimiterEnable bool, rateLimiterMaxRequests int, rateDurationInSeconds int) func(*fiber.Ctx) error

func RateLimiterJobs

func RateLimiterJobs(rateLimiterEnable bool, rateLimiterMaxRequests int, rateDurationInSeconds int) func(*fiber.Ctx) error

func RateLimiterStreams

func RateLimiterStreams(rateLimiterEnable bool, rateLimiterMaxRequests int, rateDurationInSeconds int) func(*fiber.Ctx) error

func RateLimiterUtils

func RateLimiterUtils(rateLimiterEnable bool) func(*fiber.Ctx) error

func ValidateStruct

func ValidateStruct(obj interface{}) []*apierror.ValidationError

Types

type GetAccountHTTPJsonResult

type GetAccountHTTPJsonResult struct {
	ID   uuid.UUID `json:"id" example:"123489e2-b483-467b-8b59-758b33981234"`
	Name string    `json:"name" example:"account name"`
}

type HTTPError

type HTTPError struct {
	Code    int    `json:"code" example:"400"`
	Message string `json:"message" example:"error"`
}

type JSONResult

type JSONResult struct {
	Code    int         `json:"code" example:"200"`
	Message string      `json:"message" example:"success"`
	Data    interface{} `json:"data"`
}

type JSONResultListStreamsProperties

type JSONResultListStreamsProperties struct {
	Code   int                                    `json:"code" example:"200"`
	Result *JSONResultListStreamsPropertiesResult `json:"result"`
}

type JSONResultListStreamsPropertiesResult

type JSONResultListStreamsPropertiesResult struct {
	Total int                                         `json:"total" example:"5"`
	Rows  *[]JSONResultListStreamsPropertiesResultRow `json:"rows"`
}

type JSONResultListStreamsPropertiesResultRow

type JSONResultListStreamsPropertiesResultRow struct {
	UUID         types.StreamUUID       `json:"uuid" example:"4ce589e2-b483-467b-8b59-758b339801db"`
	CptMessages  types.Size64           `json:"cptMessages" example:"12345"`
	SizeInBytes  types.Size64           `json:"sizeInBytes" example:"4567890"`
	CreationDate time.Time              `json:"creationDate"`
	LastUpdate   time.Time              `json:"lastUpdate"`
	Properties   types.StreamProperties `json:"properties"`
	LastMsgId    types.MessageId        `json:"lastMsgId"`
}

type JSONResultListUsers

type JSONResultListUsers struct {
	Code  int      `json:"code" example:"200"`
	Users []string `json:"users"`
}

type JSONResultPbkdf2

type JSONResultPbkdf2 struct {
	Code       int    `json:"code" example:"200"`
	Message    string `json:"message" example:"success"`
	Hash       string `json:"hash"`
	Digest     string `json:"digest"`
	Iterations int    `json:"iterations"`
	Salt       string `json:"salt"`
}

type JSONResultSuccess

type JSONResultSuccess struct {
	Code    int    `json:"code" example:"200"`
	Message string `json:"message" example:"success"`
}

type JWTManager added in v1.5.0

type JWTManager struct {
	// contains filtered or unexported fields
}
var JWTMgr JWTManager

func (*JWTManager) Finalize added in v1.5.0

func (m *JWTManager) Finalize()

func (*JWTManager) GenerateJWT added in v1.5.0

func (m *JWTManager) GenerateJWT(isSuperUser bool, accessKeyId string, secretAccessKey string) (bool, string, *jwt.MapClaims, *rbac.User, error)

func (*JWTManager) Initialize added in v1.5.0

func (m *JWTManager) Initialize(conf config.JWTConfig)

func (*JWTManager) ResetConfig added in v1.5.0

func (m *JWTManager) ResetConfig()

func (*JWTManager) RevokeAll added in v1.5.0

func (m *JWTManager) RevokeAll()

type Pbkdf2Payload

type Pbkdf2Payload struct {
	Digest     string `json:"digest" validate:"required" example:"sha256"`
	Iterations int    `json:"iterations" validate:"min=1,max=10000"`
	Salt       string `json:"salt" validate:"required" example:"thisisarandomsalt"`
	Password   string `json:"password" validate:"required" example:"thisismysecretpassword"`
}

type WebAPIServer added in v1.5.0

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

func NewWebAPIServer added in v1.5.0

func NewWebAPIServer(appConfig *config.Config, fiberConfig fiber.Config, service *service.Service, funcShutdownServer func(), funcRestartServer func()) *WebAPIServer

func (*WebAPIServer) ActionJWTRevokeAll added in v1.5.0

func (w *WebAPIServer) ActionJWTRevokeAll(c *fiber.Ctx) error

ActionJWTRevokeAll godoc @Summary Reload server authentication configuration @Description Reload server authentication configuration @ID server-jwt-revoke-all @Accept json @Produce json @Tags Admin @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/admin/jwt/revoke [post]

func (*WebAPIServer) AddRoutes added in v1.5.0

func (w *WebAPIServer) AddRoutes(app *fiber.App)

func (*WebAPIServer) ApiServerRestart added in v1.5.0

func (w *WebAPIServer) ApiServerRestart(c *fiber.Ctx) error

ApiServerRestart godoc @Summary Restart server @Description Restart server @ID server-restart @Accept json @Produce json @Tags Admin @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/admin/server/restart [post]

func (*WebAPIServer) ApiServerShutdown added in v1.5.0

func (w *WebAPIServer) ApiServerShutdown(c *fiber.Ctx) error

ApiServerShutdown godoc @Summary Shutdown server @Description Shutdown server @ID server-shutdown @Accept json @Produce json @Tags Admin @success 200 {object} web.JSONResultSuccess{} "successful operation" @Router /api/v1/admin/server/shutdown [post]

func (*WebAPIServer) ApiServerUtilsPbkdf2 added in v1.5.0

func (w *WebAPIServer) ApiServerUtilsPbkdf2(c *fiber.Ctx) error

ApiServerUtilsPbkdf2 godoc @Summary Generate hash from password @Description Generate hash from password @ID utils-pbkdf2 @Accept json @Produce json @Tags Utils @Param payload body Pbkdf2Payload true "Pbkdf2Payload" Format(Pbkdf2Payload) @Success 200 {object} web.JSONResultPbkdf2 "successful operation" @Failure 400 {object} apierror.APIError @Router /api/v1/utils/pbkdf2 [post]

func (*WebAPIServer) CloseRecordsIterator added in v1.5.0

func (w *WebAPIServer) CloseRecordsIterator(c *fiber.Ctx) error

CloseRecordsIterator godoc @Summary Close a stream records iterator @Description Close an existing stream records iterator by it's UUID @ID stream-close-records-iterator @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Param streamiteratoruuid path string true "Stream iterator UUID" Format(uuid.UUID) @Success 200 {object} stream.CloseRecordsIteratorResponse "successful operation" @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/iterator/{streamiteratoruuid} [delete]

func (*WebAPIServer) CreateRecordsIterator added in v1.5.0

func (w *WebAPIServer) CreateRecordsIterator(c *fiber.Ctx) error

CreateRecordsIterator godoc @Summary Create stream records iterator @Description Create a record iterator to get records from a given position for the given stream UUID @ID stream-create-records-iterator @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} stream.CreateRecordsIteratorResponse @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/iterator [post]

func (*WebAPIServer) CreateStream added in v1.5.0

func (w *WebAPIServer) CreateStream(c *fiber.Ctx) error

CreateStream godoc @Summary Create a stream @Description Create a new stream @ID stream-create @Accept json @Produce json @Tags Stream @Success 201 {array} types.StreamInfo @Success 400 {object} apierror.APIError @Router /api/v1/stream [post]

func (*WebAPIServer) DeleteStream added in v1.5.0

func (w *WebAPIServer) DeleteStream(c *fiber.Ctx) error

DeleteStream godoc @Summary Delete a stream @Description Delete a stream @ID stream-delete @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @success 200 {object} web.JSONResultSuccess{} "successful operation" @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid} [delete]

func (*WebAPIServer) GetAccount added in v1.5.0

func (w *WebAPIServer) GetAccount(c *fiber.Ctx) error

GetAccount godoc @Summary Get account @Description Get account details @ID account-get @Accept json @Produce json @Tags Account @success 200 {object} web.JSONResult{data=web.GetAccountHTTPJsonResult{}} "successful operation" @Router /api/v1/account [get]

func (*WebAPIServer) GetFiberApp added in v1.5.1

func (w *WebAPIServer) GetFiberApp() *fiber.App

func (*WebAPIServer) GetRecords added in v1.5.0

func (w *WebAPIServer) GetRecords(c *fiber.Ctx) error

GetRecords godoc @Summary Get stream records @Description Get records for the given stream UUID @ID stream-get-records @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Param streamiteratoruuid path string true "Stream iterator UUID" Format(uuid.UUID) @Param maxRecords query int false "int max records" example(10) @Success 200 {object} stream.GetStreamRecordsResponse "successful operation" @Success 400 {object} apierror.APIError @Success 500 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/iterator/{streamiteratoruuid}/records [get]

func (*WebAPIServer) GetRecordsIteratorStats added in v1.5.0

func (w *WebAPIServer) GetRecordsIteratorStats(c *fiber.Ctx) error

GetRecordsIteratorStats godoc @Summary Get statistics about a stream records iterator @Description Get statistics for the given stream UUID and stream record iterator UUID @ID stream-get-records-iterator-stats @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Param streamiteratoruuid path string true "Stream iterator UUID" Format(uuid.UUID) @Success 200 {object} stream.GetRecordsIteratorStatsResponse "successful operation" @Success 400 {object} apierror.APIError @Success 500 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/iterator/{streamiteratoruuid}/stats [get]

func (*WebAPIServer) GetStreamFromParameter added in v1.5.0

func (w *WebAPIServer) GetStreamFromParameter(c *fiber.Ctx) (types.StreamUUID, *stream.Stream, *apierror.APIError)

func (*WebAPIServer) GetStreamInformation added in v1.5.0

func (w *WebAPIServer) GetStreamInformation(c *fiber.Ctx) error

GetStreamInformation godoc @Summary Get stream information @Description Get information for the given stream UUID @ID stream-get-information @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} types.StreamInfo @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid} [get]

func (*WebAPIServer) GetStreamProperties added in v1.5.0

func (w *WebAPIServer) GetStreamProperties(c *fiber.Ctx) error

GetStreamProperties godoc @Summary Get stream properties @Description Get the properties for the given stream UUID @ID stream-get-properties @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} types.StreamProperties "successful operation" @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/properties [get]

func (*WebAPIServer) GetStreamPropertiesForABAC added in v1.5.0

func (w *WebAPIServer) GetStreamPropertiesForABAC(c *fiber.Ctx) (interface{}, error)

func (*WebAPIServer) GetStreamUUIDFromParameter added in v1.5.0

func (w *WebAPIServer) GetStreamUUIDFromParameter(c *fiber.Ctx) (types.StreamUUID, *apierror.APIError)

func (*WebAPIServer) ListStreams added in v1.5.0

func (w *WebAPIServer) ListStreams(c *fiber.Ctx) error

ListStreams godoc @Summary List streams @Description Get the list of all streams UUIDs @ID stream-list @Accept json @Produce json @Tags Stream @Param jq query string false "string jq filter" example(".name == \"test 8\"") @Success 200 {array} types.StreamUUID "successful operation" @Failure 403 {object} apierror.APIError @Router /api/v1/streams [get]

func (*WebAPIServer) ListStreamsProperties added in v1.5.0

func (w *WebAPIServer) ListStreamsProperties(c *fiber.Ctx) error

ListStreamsProperties godoc @Summary List streams properties @Description Get the streams UUIDs and their properties @ID stream-list-and-properties @Accept json @Produce json @Tags Stream @Param jq query string false "string jq filter" example(".name == \"test 8\"") @Success 200 {object} web.JSONResultListStreamsProperties "successful operation" @Failure 403 {object} apierror.APIError @Router /api/v1/streams/properties [get]

func (*WebAPIServer) ListUsers added in v1.5.0

func (w *WebAPIServer) ListUsers(c *fiber.Ctx) error

ListUsers godoc @Summary List users @Description Get the list of users @ID user-list @Accept json @Produce json @Tags User @Success 200 {object} web.JSONResultListUsers "successful operation" @Router /api/v1/users [get]

func (*WebAPIServer) LoginAccount added in v1.5.0

func (w *WebAPIServer) LoginAccount(c *fiber.Ctx) error

LoginAccount godoc @Summary Account login @Description Account login @ID account-login @Accept json @Produce json @Tags Account @Param API-KEY header string true "API-KEY" @Success 200 {object} stream.LoginAccountResponse "successful operation" @Failure 400 {object} apierror.APIError @Failure 403 {object} apierror.APIError @Router /api/v1/account/login [get]

func (*WebAPIServer) LoginUser added in v1.5.0

func (w *WebAPIServer) LoginUser(c *fiber.Ctx) error

LoginUser godoc @Summary Logs user into the system @Description Logs user into the system @ID user-login @Accept json @Produce json @Tags User @Param ACCESS-KEY-ID header string true "ACCESS-KEY-ID" @Param SECRET-ACCESS-KEY header string true "SECRET-ACCESS-KEY" @Success 200 {object} stream.LoginUserResponse "successful operation" @Success 400 {object} apierror.APIError @Success 403 {object} apierror.APIError @Success 500 {object} apierror.APIError @Router /api/v1/user/login [get]

func (*WebAPIServer) Ping added in v1.5.0

func (w *WebAPIServer) Ping(c *fiber.Ctx) error

Ping godoc @Summary Ping server @Description Ping server @ID utils-ping @Produce plain @Tags Utils @Success 200 {string} string "ok" @Router /api/v1/utils/ping [get]

func (*WebAPIServer) PutRecord added in v1.5.0

func (w *WebAPIServer) PutRecord(c *fiber.Ctx) error

PutRecord godoc @Summary Put one record into a stream @Description Put a single record into a stream @ID stream-put-record @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 202 {object} stream.PutStreamRecordsResponse "successful operation" @Success 400 {object} apierror.APIError @Success 500 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/record [put]

func (*WebAPIServer) PutRecords added in v1.5.0

func (w *WebAPIServer) PutRecords(c *fiber.Ctx) error

PutRecords godoc @Summary Put one or multiple records into a stream @Description Put one or multiple records into a stream @ID stream-put-records @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 202 {object} stream.PutStreamRecordsResponse "successful operation" @Success 400 {object} apierror.APIError @Success 500 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/records [put]

func (*WebAPIServer) RebuildIndex added in v1.5.0

func (w *WebAPIServer) RebuildIndex(c *fiber.Ctx) error

RebuildIndex godoc @Summary Rebuild the stream index @Description Build or rebuild the stream index @ID stream-rebuild-index @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} stream.RebuildStreamIndexResponse @Success 500 {object} apierror.APIError @Router /api/v1/stream/index/{streamuuid}/rebuild [post]

func (*WebAPIServer) RestartServer added in v1.5.0

func (w *WebAPIServer) RestartServer()

func (*WebAPIServer) SetStreamProperties added in v1.5.0

func (w *WebAPIServer) SetStreamProperties(c *fiber.Ctx) error

SetStreamProperties godoc @Summary Set stream properties @Description Set and replace properties for the given stream @ID stream-set-properties @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} types.StreamProperties "successful operation" @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/properties [post]

func (*WebAPIServer) ShutdownServer added in v1.5.0

func (w *WebAPIServer) ShutdownServer()

func (*WebAPIServer) UpdateStreamProperties added in v1.5.0

func (w *WebAPIServer) UpdateStreamProperties(c *fiber.Ctx) error

UpdateStreamProperties godoc @Summary Update stream properties @Description update properties for the given stream @ID stream-update-properties @Accept json @Produce json @Tags Stream @Param streamuuid path string true "Stream UUID" Format(uuid.UUID) @Success 200 {object} types.StreamProperties "successful operation" @Success 400 {object} apierror.APIError @Router /api/v1/stream/{streamuuid}/properties [patch]

func (*WebAPIServer) ValidateApiKey added in v1.5.0

func (w *WebAPIServer) ValidateApiKey(c *fiber.Ctx) error

ValidateApiKey godoc @Summary Validate API Key @Description Log in a user @ID account-validate-api-key @Accept json @Produce json @Tags Account @Param API-KEY header string true "API-KEY" @success 200 {object} web.JSONResultSuccess{} "successful operation" @Failure 400 {object} apierror.APIError @Failure 403 {object} apierror.APIError @Router /api/v1/account/validate [get]

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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