Documentation
¶
Index ¶
- func ConstructBoolQuery(key string, value string) *map[string]interface{}
- func CreateNewDocumentInIndex(index string, document *Document) error
- func CreateNewIndex(index string, mapping string) error
- func GenerateToken(email string) (string, error)
- func HashPassword(password string) string
- func MigrateIndex() error
- type Claims
- type Document
- type EsConnector
- type EsService
- type Rsa
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstructBoolQuery ¶
ConstructBoolQuery returns a query for the SearchWithKeyWord method
func CreateNewDocumentInIndex ¶
CreateNewDocumentInIndex inserts a new document in elastic search. take the index and a pointer of Document as parameters. returns an error
func CreateNewIndex ¶
CreateNewIndex allows you to create a new elastic search index. Checks if index already exists
func GenerateToken ¶
GenerateToken creates a JWT with email and expiration time in the payload
func HashPassword ¶
HashPassword takes a string in parameter and returns the same string hashed with sha512
Types ¶
type Claims ¶
type Claims struct { Email string jwt.StandardClaims }
Claims is the struct for the token claims
func DecodeToken ¶
DecodeToken decode and validates a token
type Document ¶
type Document struct { ID string Body interface{} }
Document model for inserting, updating an elastic search document.
type EsConnector ¶
type EsConnector struct { }
type EsService ¶
type EsService interface { SearchWithKeyword(index string, query map[string]interface{}) CreateNewIndex(index string) error CreateNewDocumentInIndex(index string, document *Document) (*Document, error) GetDocumentById(index string, id string) (*Document, error) }
EsService interfaces all the methods related to elastic search.
type Rsa ¶
type Rsa struct { PublicKeyPath string PrivateKeyPath string PublicKey interface{} PrivateKey interface{} }
Rsa is the struct to get the rsa keys used to generate and verify tokens from the environment variables
type SearchResult ¶
type SearchResult struct { ID interface{} Body interface{} }
SearchResult is used essentially for mapping the search results gathered by SearchWithKeyword
func SearchWithKeyword ¶
func SearchWithKeyword(index string, query *map[string]interface{}) []*SearchResult
SearchWithKeyword perform a search call through elastic search api.