flamingo.me/flamingo-commerce/v3@v3.11.0/search/module.go (about)

     1  package search
     2  
     3  import (
     4  	"flamingo.me/dingo"
     5  	"flamingo.me/flamingo-commerce/v3/search/interfaces"
     6  	searchgraphql "flamingo.me/flamingo-commerce/v3/search/interfaces/graphql"
     7  	"flamingo.me/flamingo/v3/framework/web"
     8  	"flamingo.me/graphql"
     9  )
    10  
    11  // Module registers our search package
    12  type Module struct{}
    13  
    14  // Configure the search URL
    15  func (m *Module) Configure(injector *dingo.Injector) {
    16  	web.BindRoutes(injector, new(routes))
    17  
    18  	injector.BindMulti(new(graphql.Service)).To(new(searchgraphql.Service))
    19  }
    20  
    21  // CueConfig defines the prefixrouter configuration
    22  func (*Module) CueConfig() string {
    23  	return `
    24  commerce: {
    25  	pagination: {
    26  		defaultPageSize: number | *50
    27  		showFirstPage: 	bool | *false
    28  		showLastPage:	bool | *false
    29  		showAroundActivePageAmount: number | *3
    30  	}
    31  }`
    32  }
    33  
    34  // FlamingoLegacyConfigAlias mapping
    35  func (*Module) FlamingoLegacyConfigAlias() map[string]string {
    36  	return map[string]string{
    37  		"pagination": "commerce.pagination",
    38  	}
    39  }
    40  
    41  type routes struct {
    42  	controller *interfaces.ViewController
    43  }
    44  
    45  func (r *routes) Inject(controller *interfaces.ViewController) {
    46  	r.controller = controller
    47  }
    48  
    49  func (r *routes) Routes(registry *web.RouterRegistry) {
    50  	registry.HandleGet("search.search", r.controller.Get)
    51  	registry.Route("/search/:type", `search.search(type, *)`)
    52  	registry.Route("/search", `search.search`)
    53  }