server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorDuplicatedUser  = errors.New("duplicated user")
	ErrorEmptyEmailOrPwd = errors.New("username and password should not be empty")
	ErrorUnauthorized    = errors.New("user not authorized")
	ErrorTokenNotFound   = errors.New("token not found")
)

error definitions

Functions

func ServeHTTP

func ServeHTTP(settings config.Schema) (err error)

ServeHTTP starts the http service @title LaunchControlD REST API @version 1.0 @description This are the documentation for the LaunchControlD REST API @contact.name API Support @contact.email u2467@apeunit.com @license.name MIT @host api.launch-control.eventivize.co @BasePath /api

Types

type APIAccount

type APIAccount struct {
	Name           string `json:"name"`
	Address        string `json:"address"`
	GenesisBalance string `json:"genesis_balance"`
	Validator      bool   `json:"validator"`
	Faucet         bool   `json:"faucet"`
}

APIAccount API safe account object

type APIEvent

type APIEvent struct {
	ID          string                      `json:"id"`
	TokenSymbol string                      `json:"token_symbol"` // token symbool
	Owner       string                      `json:"owner"`        // email address of the owner
	Accounts    map[string]APIAccount       `json:"accounts"`
	Provider    string                      `json:"provider"` // provider for provisioning
	CreatedOn   time.Time                   `json:"created_on"`
	StartsOn    time.Time                   `json:"starts_on"`
	EndsOn      time.Time                   `json:"ends_on"`
	State       map[string]APIMachineConfig `json:"state"`
}

APIEvent API safe event object

func ToAPIEvent

func ToAPIEvent(evt *model.Event) (aEvt APIEvent)

ToAPIEvent convert and Event to an APIEvent that is safe to publish via REST API Endpoints

func ToAPIEvents

func ToAPIEvents(evts *[]model.Event) (aEvts []APIEvent)

ToAPIEvents copy a list of events to a API save version

type APIMachineConfig

type APIMachineConfig struct {
	TendermintNodeID string `json:"tendermint_node_id"`
	IPAddress        string `json:"IPAddress"`
	MachineName      string `json:"MachineName"`
}

APIMachineConfig API safe machine config

type APIReply

type APIReply struct {
	Status  int    `json:"code"`
	Message string `json:"message"`
}

APIReply a reply from the API

func APIReplyErr

func APIReplyErr(code int, m string) APIReply

APIReplyErr error reply

func APIReplyOK

func APIReplyOK(m string) APIReply

APIReplyOK returns an 200 reply

type APIStatus

type APIStatus struct {
	Status  string `json:"status,omitempty"`
	Version string `json:"version,omitempty"`
	Uptime  string `json:"uptime,omitempty"`
}

APIStatus hold the status of the API

type User

type User struct {
	Email        string
	PasswordHash string
}

User a user in the user database

type UserCredentials

type UserCredentials struct {
	Email string `json:"email,omitempty"`
	Pass  string `json:"pass,omitempty"`
}

UserCredentials the input user credential for authentication

type UsersDB

type UsersDB struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

UsersDB keep the users database

func NewUserDB

func NewUserDB(dbPath string) (db *UsersDB, err error)

NewUserDB create or read an existing database from a path

func (*UsersDB) DropToken

func (db *UsersDB) DropToken(token string)

DropToken deletes a token

func (*UsersDB) GetEmailFromToken

func (db *UsersDB) GetEmailFromToken(token string) (email string, err error)

GetEmailFromToken retrieve the email associated to a token

func (*UsersDB) IsAuthorized

func (db *UsersDB) IsAuthorized(email, pass string) (token string, err error)

IsAuthorized verify if a use is authorized, if so, register a user token and returns it

func (*UsersDB) IsTokenAuthorized

func (db *UsersDB) IsTokenAuthorized(token string) (email string, err error)

IsTokenAuthorized check whenever the token exists and returns the associated email otherwise returns error

func (*UsersDB) RegisterUser

func (db *UsersDB) RegisterUser(email, pass string) (err error)

RegisterUser register a new user into the user database

Jump to

Keyboard shortcuts

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