webserver

package
v0.0.0-...-b3fc11c Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2023 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// kubernetes
	LivenessPath  = "/liveness"
	ReadinessPath = "/readiness"

	// core model
	UserPath         = "/user"
	UserTimelinePath = "/user/timeline"
	UserMessagesPath = "/user/messages"
	UsersPath        = "/users"
	MessagePath      = "/message"
	MessagesPath     = "/messages"
	FollowPath       = "/follow"
	FollowersPath    = "/followers"
	UpvotePath       = "/upvote"

	// hacks
	DumpPath  = "/dump"
	SleepPath = "/sleep"
)

Variables

This section is empty.

Functions

func FindKeyInJson

func FindKeyInJson(json any, path []any, key string) [][]any

func Handler

func Handler(maxSize int64, methodHandlers map[string]func(ctx context.Context, body string, values url.Values) (any, error)) func(w http.ResponseWriter, r *http.Request)

func RequestHandler

func RequestHandler(r *http.Request, process func(ctx context.Context, body string, urlParams url.Values) (any, error)) (int, any, error)

func Run

func Run(port int, tp trace.TracerProvider, db *sql.DB)

func SetupHTTPServer

func SetupHTTPServer(responder Responder, tp trace.TracerProvider) *http.ServeMux

Types

type Action

type Action struct {
	Name string
	F    func() error
}

type Client

type Client struct {
	URL   string
	Resty *resty.Client
}

func NewClient

func NewClient(url string) *Client

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, request *CreateMessageRequest) (*CreateMessageResponse, error)

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, request *CreateUserRequest) (*CreateUserResponse, error)

func (*Client) FollowUser

func (c *Client) FollowUser(ctx context.Context, request *FollowRequest) (*FollowResponse, error)

func (*Client) GetFollowers

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, request *GetMessageRequest) (*GetMessageResponse, error)

func (*Client) GetMessages

func (c *Client) GetMessages(ctx context.Context, request *GetMessagesRequest) (*GetMessagesResponse, error)

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, request *GetUserRequest) (*GetUserResponse, error)

func (*Client) GetUserMessages

func (c *Client) GetUserMessages(ctx context.Context, request *GetUserMessagesRequest) (*GetUserMessagesResponse, error)

func (*Client) GetUserTimeline

func (c *Client) GetUserTimeline(ctx context.Context, request *GetUserTimelineRequest) (*GetUserTimelineResponse, error)

func (*Client) GetUsers

func (c *Client) GetUsers(ctx context.Context, request *GetUsersRequest) (*GetUsersResponse, error)

func (*Client) SearchMessages

func (c *Client) SearchMessages(ctx context.Context, request *SearchMessagesRequest) (*SearchMessagesResponse, error)

func (*Client) SearchUsers

func (c *Client) SearchUsers(ctx context.Context, request *SearchUsersRequest) (*SearchUsersResponse, error)

func (*Client) UpvoteMessage

func (c *Client) UpvoteMessage(ctx context.Context, request *CreateUpvoteRequest) (*CreateUpvoteResponse, error)

type CreateMessageRequest

type CreateMessageRequest struct {
	SenderUserId uuid.UUID
	Content      string
}

type CreateMessageResponse

type CreateMessageResponse struct {
	MessageId uuid.UUID
	Request   *CreateMessageRequest
}

type CreateUpvoteRequest

type CreateUpvoteRequest struct {
	UserId    uuid.UUID
	MessageId uuid.UUID
}

type CreateUpvoteResponse

type CreateUpvoteResponse struct {
	UpvoteId uuid.UUID
	Request  *CreateUpvoteRequest
}

type CreateUserRequest

type CreateUserRequest struct {
	Name  string
	Email string
}

type CreateUserResponse

type CreateUserResponse struct {
	UserId  uuid.UUID
	Request *CreateUserRequest
}

type FollowRequest

type FollowRequest struct {
	FolloweeUserId uuid.UUID
	FollowerUserId uuid.UUID
}

type FollowResponse

type FollowResponse struct {
	Request *FollowRequest
}

type GetFollowersOfUserRequest

type GetFollowersOfUserRequest struct {
	UserId uuid.UUID
}

type GetFollowersOfUserResponse

type GetFollowersOfUserResponse struct {
	Followers []GetUserResponse
	Request   *GetFollowersOfUserRequest
}

type GetMessageRequest

type GetMessageRequest struct {
	MessageId uuid.UUID
}

type GetMessageResponse

type GetMessageResponse struct {
	MessageId    uuid.UUID
	SenderUserId uuid.UUID
	Content      string
	UpvoteCount  int
}

type GetMessagesRequest

type GetMessagesRequest struct {
}

type GetMessagesResponse

type GetMessagesResponse struct {
	Messages []GetMessageResponse
	Request  *GetMessagesRequest
}

type GetUserMessagesRequest

type GetUserMessagesRequest struct {
	UserId uuid.UUID
}

type GetUserMessagesResponse

type GetUserMessagesResponse struct {
	UserId   uuid.UUID
	Messages []GetMessageResponse
	Request  *GetUserMessagesRequest
}

type GetUserRequest

type GetUserRequest struct {
	UserId uuid.UUID
}

type GetUserResponse

type GetUserResponse struct {
	UserId uuid.UUID
	Name   string
	Email  string
}

type GetUserTimelineRequest

type GetUserTimelineRequest struct {
	UserId uuid.UUID
}

type GetUserTimelineResponse

type GetUserTimelineResponse struct {
	UserId   uuid.UUID
	Messages []GetMessageResponse
	Request  *GetUserTimelineRequest
}

type GetUsersRequest

type GetUsersRequest struct {
}

type GetUsersResponse

type GetUsersResponse struct {
	Users   []GetUserResponse
	Request *GetUsersRequest
}

type Model

type Model struct {
	Live  bool
	Ready bool
	// contains filtered or unexported fields
}

func NewModel

func NewModel(ctx context.Context, tp trace.TracerProvider, db *sql.DB) *Model

func (*Model) CreateMessage

func (m *Model) CreateMessage(ctx context.Context, req *CreateMessageRequest) (*CreateMessageResponse, error)

func (*Model) CreateUpvote

func (m *Model) CreateUpvote(ctx context.Context, req *CreateUpvoteRequest) (*CreateUpvoteResponse, error)

func (*Model) CreateUser

func (m *Model) CreateUser(ctx context.Context, req *CreateUserRequest) (*CreateUserResponse, error)

func (*Model) Dump

func (m *Model) Dump(ctx context.Context) (string, error)

func (*Model) Follow

func (m *Model) Follow(ctx context.Context, req *FollowRequest) (*FollowResponse, error)

func (*Model) GetFollowers

func (*Model) GetMessage

func (m *Model) GetMessage(ctx context.Context, req *GetMessageRequest) (*GetMessageResponse, error)

func (*Model) GetMessages

func (m *Model) GetMessages(ctx context.Context, req *GetMessagesRequest) (*GetMessagesResponse, error)

func (*Model) GetUser

func (m *Model) GetUser(ctx context.Context, req *GetUserRequest) (*GetUserResponse, error)

func (*Model) GetUserMessages

func (m *Model) GetUserMessages(ctx context.Context, req *GetUserMessagesRequest) (*GetUserMessagesResponse, error)

func (*Model) GetUserTimeline

func (m *Model) GetUserTimeline(ctx context.Context, req *GetUserTimelineRequest) (*GetUserTimelineResponse, error)

func (*Model) GetUsers

func (m *Model) GetUsers(ctx context.Context, req *GetUsersRequest) (*GetUsersResponse, error)

func (*Model) IsLive

func (m *Model) IsLive(ctx context.Context) bool

func (*Model) IsReady

func (m *Model) IsReady(ctx context.Context) bool

func (*Model) SearchMessages

func (m *Model) SearchMessages(ctx context.Context, req *SearchMessagesRequest) (*SearchMessagesResponse, error)

func (*Model) SearchUsers

func (m *Model) SearchUsers(ctx context.Context, req *SearchUsersRequest) (*SearchUsersResponse, error)

func (*Model) Sleep

func (m *Model) Sleep(ctx context.Context, milliseconds string) error

type SearchMessagesRequest

type SearchMessagesRequest struct {
	LiteralString string
}

type SearchMessagesResponse

type SearchMessagesResponse struct {
	Messages []GetMessageResponse
	Request  *SearchMessagesRequest
}

type SearchUsersRequest

type SearchUsersRequest struct {
	NamePattern  string
	EmailPattern string
}

type SearchUsersResponse

type SearchUsersResponse struct {
	Users   []GetUserResponse
	Request *SearchUsersRequest
}

Jump to

Keyboard shortcuts

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