http

package
v0.0.0-...-b23f8ac Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPRouter

func NewHTTPRouter(
	logger *logrus.Entry,
	handlers RouterHandlers,
) *http.Server

Types

type AllChatsProjectionChat

type AllChatsProjectionChat struct {
	ChatID        string `json:"chat_id"`
	Title         string `json:"title"`
	MessagesCount int    `json:"messages_count"`
	Users         []User `json:"users"`
}

type AllChatsResponse

type AllChatsResponse struct {
	Chats []AllChatsProjectionChat `json:"chats"`
}

type AllChatsUpdatedRequest

type AllChatsUpdatedRequest struct {
	UserID string `json:"user_id"`
}

type AllChatsUpdatedSSEHandler

type AllChatsUpdatedSSEHandler struct {
	AllChatsUpdated http.HandlerFunc
}

type Chat

type Chat struct {
	UUID     string    `json:"uuid"`
	Title    string    `json:"title"`
	Messages []Message `json:"messages"`
}

type ChatRepository

type ChatRepository interface {
	ChatByID(ctx context.Context, chatID domain.UUID) (domain.Chat, error)
}

type ChatUpdatedSSEHandler

type ChatUpdatedSSEHandler struct {
	ChatUpdated http.HandlerFunc
}

func NewChatUpdatedSSEHandler

func NewChatUpdatedSSEHandler(sseRouter *watermillHttp.SSERouter, repository ChatRepository, logger watermill.LoggerAdapter) ChatUpdatedSSEHandler

type CreateChatHandler

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

func NewCreateChatHandler

func NewCreateChatHandler(logger watermill.LoggerAdapter, pubsub pubsub.PubSub, ctx context.Context) CreateChatHandler

func (CreateChatHandler) Handle

type CreateChatRequest

type CreateChatRequest struct {
	Name    string   `json:"name"`
	UserIDs []string `json:"user_ids"` // array of User uuids
}

type ErrorMessage

type ErrorMessage struct {
	// Application-level error message, for debugging
	Error *string `json:"error,omitempty"`

	// User-level status message
	Status string `json:"status"`
}

ErrorMessage defines model for ErrorMessage.

type Message

type Message struct {
	AuthorId string `json:"author_id"`
	Text     string `json:"text"`
}

type RouterHandlers

type RouterHandlers struct {
	ChatUpdated     ChatUpdatedSSEHandler
	AllChatsUpdated AllChatsUpdatedSSEHandler
	SendMessage     SendMessageHandler
	CreateChat      CreateChatHandler
}

func NewHandlers

func NewHandlers(
	ctx context.Context,
	logger watermill.LoggerAdapter,
	sseRouter *watermillHttp.SSERouter,
	repository ChatRepository,
	pubsub pubsub.PubSub,
) RouterHandlers

type SendMessageHandler

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

func NewSendMessageHandler

func NewSendMessageHandler(logger watermill.LoggerAdapter, pubsub pubsub.PubSub, ctx context.Context) SendMessageHandler

func (SendMessageHandler) Handle

type SendMessageRequest

type SendMessageRequest struct {
	Message Message `json:"message"`
}

type User

type User struct {
	UserID   string `json:"user_id"`
	Username string `json:"username"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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