MCPcopy
hub / github.com/perkeep/perkeep / InitHandler

Method InitHandler

pkg/server/app/app.go:439–454  ·  view source on GitHub ↗

InitHandler sets the app handler's search handler, if the app handler was configured to have one with HasSearch.

(hl blobserver.FindHandlerByTyper)

Source from the content-addressed store, hash-verified

437// InitHandler sets the app handler's search handler, if the app handler was configured
438// to have one with HasSearch.
439func (a *Handler) InitHandler(hl blobserver.FindHandlerByTyper) error {
440 apName := a.ProgramName()
441 searchPrefix, _, err := hl.FindHandlerByType("search")
442 if err != nil {
443 return fmt.Errorf("No search handler configured, which is necessary for the %v app handler", apName)
444 }
445 var sh *search.Handler
446 _, hi := hl.AllHandlers()
447 h, ok := hi[searchPrefix]
448 if !ok {
449 return fmt.Errorf("failed to find the \"search\" handler for %v", apName)
450 }
451 sh = h.(*search.Handler)
452 a.sh = sh
453 return nil
454}
455
456func (a *Handler) Start() error {
457 name := a.name

Callers

nothing calls this directly

Calls 3

ProgramNameMethod · 0.95
FindHandlerByTypeMethod · 0.65
AllHandlersMethod · 0.65

Tested by

no test coverage detected