backend

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	DB *gorm.DB
}

Database holds the state of the persistant storage.

func NewDatabase

func NewDatabase(connection string) (*Database, error)

NewDatabase creates a new persistant storage instance. connection holds the MySQL connection string, which is passed through to the database layer.

func (*Database) Close

func (m *Database) Close() error

Close closes the persistant storage instance.

func (*Database) CreateDomain

func (m *Database) CreateDomain(name string) error

CreateDomain creates a new domain with the given name. If a domain with the same name exists, an error is returned.

func (*Database) CreateForward

func (m *Database) CreateForward(name string, from string, to string) error

CreateForward created a new email forward for a domain. The domain is identified by its name. The forward is defined by the from email and to to email. If no domain with the given name exists, an error is returned. If a forward with the same from address already exists, an error is returned.

func (*Database) DeleteDomain

func (m *Database) DeleteDomain(name string) error

DeleteDomain deletes an existing domain, specified by its name. All associated forwards of the domain will be deleted as well. If no domain with the given name exists, an error is returned.

func (*Database) DeleteForward

func (m *Database) DeleteForward(name string, from string) error

DeleteForward deletes an existing forward for a domain. The domain is identified by its name. The forward is identified by the from email. If no domain with the given name exists, an error is returned.

func (*Database) Domains

func (m *Database) Domains() ([]*Domain, error)

Domains returns a list of all domains, including the associated email forwards.

func (*Database) UpdateForward

func (m *Database) UpdateForward(name string, from string, to string) error

UpdateForward updates an existing forward for a domain. The domain is identified by its name. The forward is identified by the from email. Only the to email can be updated. If no domain with the given name exists, an error is returned. If no forward with the given from address exists, an error is returned.

type Domain

type Domain struct {
	Name     string     `json:"name"`
	Forwards []*Forward `json:"forwards"`
}

Domain is the caller-facing replica of the internal database model. It contains the state of the room domain object, with reference to all email forwards.

type Forward

type Forward struct {
	From string `json:"from"`
	To   string `json:"to"`
}

Forward is the caller-facing replica of the internal database model. It contains the state of the leaf email forward object.

type Server

type Server struct {
	Router *mux.Router
	DB     *Database
}

Server holds the state of a HTTP server. The HTTP server exposes REST methods to manipulate domains and their associated (email) forwards.

func NewServer

func NewServer(assetPath string, mysql string) (*Server, error)

NewServer creates a new server. assetPath points to a folder with static web content. If assetPath is empty, the web content is loaded from the embedded filesystem. mysql holds the MySQL connection string, which is passed through to the database layer.

func (*Server) Close

func (m *Server) Close() error

Close closes the server.

Jump to

Keyboard shortcuts

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