Documentation
¶
Index ¶
- Constants
- func ReqLog(Logger zerolog.Logger, w http.ResponseWriter, r *http.Request, s time.Time, ...)
- type DestStruct
- type FinalStruct
- type LoggingHandler
- type RandomContinue
- type RandomPage
- type RandomQuery
- type RandomResult
- type RedisHandler
- type Search
- type SearchContinue
- type SearchInfo
- type SearchQuery
- type SearchResult
- type SourceStruct
- type UIHandler
- func (h *UIHandler) DestRoute(w http.ResponseWriter, r *http.Request)
- func (h *UIHandler) FinalRoute(w http.ResponseWriter, r *http.Request)
- func (u *UIHandler) HealthRoute(w http.ResponseWriter, r *http.Request)
- func (h *UIHandler) Path(src, dst string) (*FinalStruct, error)
- func (h *UIHandler) Random() ([]string, error)
- func (h *UIHandler) Search(query string) ([]string, error)
- func (u *UIHandler) Serve(addr string) error
- func (h *UIHandler) SourceRoute(w http.ResponseWriter, r *http.Request)
Constants ¶
View Source
const WikiRandomEndpoint = `https://he.wikipedia.org/w/api.php?action=query&generator=random&grnnamespace=0&grnlimit=8&utf8=&format=json`
View Source
const WikiSearchEndpoint = `https://he.wikipedia.org/w/api.php?action=query&list=search&srnamespace=0&srlimit=8&utf8=&format=json&srsearch=`
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DestStruct ¶
type FinalStruct ¶
type LoggingHandler ¶
type LoggingHandler struct { Logger zerolog.Logger Session *session.Session Svc *cloudwatchlogs.CloudWatchLogs }
LoggingHandler logs to disk and cloudwatch
func MakeLoggingHandler ¶
type RandomContinue ¶
type RandomPage ¶
type RandomQuery ¶
type RandomQuery struct {
Pages map[string]RandomPage `json:"pages"`
}
type RandomResult ¶
type RandomResult struct { Batchcomplete string `json:"batchcomplete"` Continue RandomContinue `json:"continue"` Query RandomQuery `json:"query"` }
Random results from wikipedia
type RedisHandler ¶
type RedisHandler struct { RedisAddress string VaultAddress string VaultRole string VaultClient *vault.Client RedisClient *redis.Client RedisTTL time.Time Logger *LoggingHandler }
func MakeRedisHandler ¶
func MakeRedisHandler(rAddr, vAddr, vRole string, logger *LoggingHandler) (*RedisHandler, error)
func (*RedisHandler) PutValue ¶
func (r *RedisHandler) PutValue(key, value string) error
type SearchContinue ¶
type SearchInfo ¶
type SearchInfo struct {
Totalhits int `json:"totalhits"`
}
type SearchQuery ¶
type SearchQuery struct { SearchInfo SearchInfo `json:"searchinfo"` Search []Search `json:"search"` }
type SearchResult ¶
type SearchResult struct { Batchcomplete string `json:"batchcomplete"` Continue SearchContinue `json:"continue"` Query SearchQuery `json:"query"` }
Search Result from Wikipedia
type SourceStruct ¶
type UIHandler ¶
type UIHandler struct { Locale string LinkAPI string Redis *RedisHandler Client *http.Client Router *chi.Mux Templates map[string]*template.Template Logger *LoggingHandler }
func MakeUIHandler ¶
func MakeUIHandler(locale, apiAddr, rAddr, vAddr, vRole string, logLevel zerolog.Level, writer io.Writer) (*UIHandler, error)
("heb", apiAddr, rAddr, rRole, vAddr, vRegion, vRole, level, logf)
func (*UIHandler) FinalRoute ¶
func (h *UIHandler) FinalRoute(w http.ResponseWriter, r *http.Request)
FinalRoute searches the path between two articles
func (*UIHandler) HealthRoute ¶
func (u *UIHandler) HealthRoute(w http.ResponseWriter, r *http.Request)
HealthRoute for health checking purposes
func (*UIHandler) Path ¶
func (h *UIHandler) Path(src, dst string) (*FinalStruct, error)
Path searches LinkAPI for a path between articles consults the redis cache for quick retrieval
func (*UIHandler) Search ¶
Search searches wikipedia for articles consults the redis cache for quick retrieval
func (*UIHandler) SourceRoute ¶
func (h *UIHandler) SourceRoute(w http.ResponseWriter, r *http.Request)
SourceRoute is the index of the applicatoin
Click to show internal directories.
Click to hide internal directories.