word

package module
v0.0.0-...-549f43f Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2016 License: MIT Imports: 9 Imported by: 0

README

WORD

Web service for doin' things with words. Yup.

Use it

Create a new database user, and give it the password of krampus when prompted

createuser -P word

Create a new database

createdb -O word word

Install goose to run the database migrations

go get bitbucket.org/liamstask/goose/cmd/goose

Run it (this will also populate the initial word list, which can take some time, so be patient)

./lazy-run

Try it from your console with

curl http://localhost:8001/api/word

Result looks like

{"id":0,"word":"glittery","rating":0}

Docker stuff

cd db && docker build -t word-db . && cd -
cd migrations && docker build -t word-migrations . && cd -
cd cmd/word && docker build -t word-app . && cd -

docker run -d --name word-db word-db
docker run --rm --link word-db:pg word-migrations
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy
docker run -d --link word-db:pg --name word-app -e VIRTUAL_HOST=word.ralreegorganon.com word-app

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRouter

func CreateRouter(server *HTTPServer) (*mux.Router, error)

Types

type DB

type DB struct {
	*sqlx.DB
}

func (*DB) DownVoteWord

func (db *DB) DownVoteWord(word string, ip string) error

func (*DB) GetBottom10

func (db *DB) GetBottom10() ([]*Word, error)

func (*DB) GetHistory

func (db *DB) GetHistory() ([]*Word, error)

func (*DB) GetRandom10

func (db *DB) GetRandom10() ([]*Word, error)

func (*DB) GetRandomWord

func (db *DB) GetRandomWord() (*Word, error)

func (*DB) GetTop10

func (db *DB) GetTop10() ([]*Word, error)

func (*DB) Open

func (db *DB) Open() error

func (*DB) UpVoteWord

func (db *DB) UpVoteWord(word string, ip string) error

type HTTPServer

type HTTPServer struct {
	DB *DB
}

func NewHTTPServer

func NewHTTPServer(db *DB) *HTTPServer

func (*HTTPServer) DownVoteWord

func (s *HTTPServer) DownVoteWord(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) GetBottom10

func (s *HTTPServer) GetBottom10(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) GetHistory

func (s *HTTPServer) GetHistory(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) GetRandom10

func (s *HTTPServer) GetRandom10(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) GetRandomWord

func (s *HTTPServer) GetRandomWord(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) GetTop10

func (s *HTTPServer) GetTop10(w http.ResponseWriter, r *http.Request, vars map[string]string) error

func (*HTTPServer) UpVoteWord

func (s *HTTPServer) UpVoteWord(w http.ResponseWriter, r *http.Request, vars map[string]string) error

type HttpApiFunc

type HttpApiFunc func(w http.ResponseWriter, r *http.Request, vars map[string]string) error

type Vote

type Vote struct {
	Id        int64 `db:"vote_id"`
	Word      string
	Vote      int64
	CreatedAt time.Time `db:"created_at"`
	IPAddress string
}

type Word

type Word struct {
	Id     int64  `json:"id" db:"word_id"`
	Word   string `json:"word"`
	Rating int64  `json:"rating"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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