server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2019 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccount

func CreateAccount(newUser string)

CreateAccount creates an account using the supplied username, then returns a randomly generated password.

func CreateConfig

func CreateConfig()

CreateConfig creates the server configuration file

func DeleteAccount

func DeleteAccount(user string)

DeleteAccount deletes an account using the supplied username

func Initialize

func Initialize() *sqlx.DB

Initialize creates the database connection

func RegeneratePassword

func RegeneratePassword(user string)

RegeneratePassword creates a new password for the supplied username

func Setup

func Setup()

Setup runs the initial setup using the supplied settings in the configuration file

Types

type AuthToken

type AuthToken struct {
	ID        int
	AccountID int `db:"account_id"`
	Token     string
	CreatedAt time.Time `db:"created_at"`
}

type Env

type Env struct {
	DB               *sqlx.DB
	StaticDir        string
	MaxFileSize      int64
	BlockedMimeTypes []string
}

func (*Env) AuthMiddleware

func (e *Env) AuthMiddleware(next http.Handler) http.Handler

func (*Env) CreateAuthToken

func (e *Env) CreateAuthToken(w http.ResponseWriter, r *http.Request)

func (*Env) DeleteFile

func (e *Env) DeleteFile(w http.ResponseWriter, r *http.Request)

func (*Env) GetFile

func (e *Env) GetFile(w http.ResponseWriter, r *http.Request)

func (*Env) ShowIndex

func (e *Env) ShowIndex(w http.ResponseWriter, r *http.Request)

func (*Env) UploadFile

func (e *Env) UploadFile(w http.ResponseWriter, r *http.Request)

type Server

type Server struct {
	DB     *sqlx.DB
	Router *chi.Mux
}

Server defines the database connection and the HTTP server of the application

func (*Server) Run

func (s *Server) Run(development bool)

Run starts the server

type User

type User struct {
	ID        int
	Username  string
	Password  string
	CreatedAt time.Time `db:"created_at"`
}

type UserFile

type UserFile struct {
	ID        int
	AccountID int `db:"account_id"`
	Name      string
	CreatedAt time.Time `db:"created_at"`
}

Jump to

Keyboard shortcuts

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