server

package
v0.0.0-...-c9273ef Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(config Config) *server

func Start

func Start(config Config)

Start instantiates the web server and opens the browser

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

type Config

type Config struct {
	Log                     bool
	Port                    string
	UserName                string
	Persist                 bool
	DownloadDir             string
	Basepath                string
	Server                  string
	EnableTLS               bool
	SearchTimeout           time.Duration
	SearchBot               string
	DisableBrowserDownloads bool
	UserAgent               string
}

Config contains settings for server

type ConnectionRequest

type ConnectionRequest struct{}

ConnectionRequest is a request to start the IRC server

type ConnectionResponse

type ConnectionResponse struct {
	StatusResponse
	Name string `json:"name"`
}

ConnectionResponse

type DownloadRequest

type DownloadRequest struct {
	Book string `json:"book"`
}

DownloadRequest is a request to download a specific book from the IRC server

type DownloadResponse

type DownloadResponse struct {
	StatusResponse
	Name         string `json:"name"`
	DownloadPath string `json:"downloadPath"`
}

DownloadResponse is a response that sends the requested book to the client

type MessageType

type MessageType int
const (
	STATUS MessageType = iota
	CONNECT
	SEARCH
	DOWNLOAD
	RATELIMIT
)

Available commands. These are sent via integers starting at 1

func (MessageType) String

func (i MessageType) String() string

type NotificationType

type NotificationType int
const (
	NOTIFY NotificationType = iota
	SUCCESS
	WARNING
	DANGER
)

type Repository

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

func NewRepository

func NewRepository() *Repository

type Request

type Request struct {
	MessageType MessageType     `json:"type"`
	Payload     json.RawMessage `json:"payload"`
}

Request in a generic structure for all requests from the websocket client

type RequestHandler

type RequestHandler interface {
	// contains filtered or unexported methods
}

RequestHandler defines a generic handle() method that is called when a specific request type is made

type SearchRequest

type SearchRequest struct {
	Query string `json:"query"`
}

SearchRequest is a request that sends a search request to the IRC server for a specific query

type SearchResponse

type SearchResponse struct {
	StatusResponse
	Books  []core.BookDetail `json:"books"`
	Errors []core.ParseError `json:"errors"`
}

SearchResponse is a response that is sent containing BookDetails objects that matched the query

type StatusResponse

type StatusResponse struct {
	MessageType      MessageType      `json:"type"`
	NotificationType NotificationType `json:"appearance"`
	Title            string           `json:"title"`
	Detail           string           `json:"detail"`
}

Jump to

Keyboard shortcuts

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