bangs

package
v0.0.0-...-73de0e8 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package bangs detects when queries should be redirected to 3rd party sites

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bang

type Bang struct {
	Triggers []string
	Name     string
	Category string
	Regions  []Region
}

Bang holds a single !bang

type Bangs

type Bangs struct {
	sync.Mutex
	M map[string]map[string]string
}

Bangs holds a map of !bangs

func New

func New() *Bangs

New creates a pointer with the default !bangs. Use default url unless a region is provided. Region: US, Language: French !a ---> Amazon.com Region: France, Language: English !a ---> Amazon.fr !afr ---> Amazon.fr Note: Some !bangs don't respect the language passed in or may not support it (eg they may support pt but not pt-BR)

TODO: Allow overrides...perhaps add a method or use a config. Note: If we end up using viper for this don't use "SetDefault" as overriding one !bang will replace ALL !bangs. Instead, use "Set".

func (*Bangs) Detect

func (b *Bangs) Detect(q, region, language string) (string, bool)

Detect lets us know if we have a !bang match.

type Region

type Region struct {
	Region   string
	Location string
}

Region holds the regional information and url of a !bang

Directories

Path Synopsis
Sample bangs demonstrates how to run a simple !bangs server
Sample bangs demonstrates how to run a simple !bangs server

Jump to

Keyboard shortcuts

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