core

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitLogger

func InitLogger(isVerbose, isDebug bool)

Types

type Browser

type Browser struct {
	BrowserOpts
	// contains filtered or unexported fields
}

func NewBrowser

func NewBrowser(opts BrowserOpts) (*Browser, error)

func (*Browser) Close

func (b *Browser) Close() error

func (*Browser) IsInitialized

func (b *Browser) IsInitialized() bool

Check whether browser instance is already created

func (*Browser) Navigate

func (b *Browser) Navigate(URL string) *rod.Page

Open URL

type BrowserOpts

type BrowserOpts struct {
	IsHeadless    bool          // Use browser interface
	IsLeakless    bool          // Force to kill browser
	Timeout       time.Duration // Timeout
	LanguageCode  string
	WaitRequests  bool // Wait requests to complete after navigation
	LeavePageOpen bool // Leave pages and browser open
}

func (*BrowserOpts) Init

func (o *BrowserOpts) Init()

Initialize browser parameters with default values if they are not set

type Query

type Query struct {
	Text         string
	LangCode     string // eg. EN, ES, RU...
	DateInterval string // format: YYYYMMDD..YYYMMDD - 20181010..20231010
	Filetype     string // File extension to search.
	Site         string // Search site
	Limit        int    // Limit the number of results
}

func (*Query) InitFromContext

func (q *Query) InitFromContext(c *fiber.Ctx) error

func (Query) IsEmpty

func (q Query) IsEmpty() bool

type SearchEngine

type SearchEngine interface {
	Search(Query) ([]SearchResult, error)
	IsInitialized() bool
	Name() string
}

type SearchResult

type SearchResult struct {
	Rank        int    `json:"rank"`
	URL         string `json:"url"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

type Server

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

func NewServer

func NewServer(host string, port int, searchEngines ...SearchEngine) *Server

func (*Server) Listen

func (s *Server) Listen() error

func (*Server) Shutdown

func (s *Server) Shutdown() error

Jump to

Keyboard shortcuts

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