trivia

package module
v0.0.0-...-11b195b Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2014 License: MIT Imports: 7 Imported by: 0

README

TRIVIA

Dumb trivia question source

No Docker

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

createuser -P trivia

Create a new database

createdb -O trivia trivia

Install goose to run the database migrations

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

Run it

./lazy-run

Docker stuff

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

docker run -d --name trivia-db trivia-db
docker run --rm --link trivia-db:pg trivia-migrations
docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock jwilder/nginx-proxy
docker run -d --link trivia-db:pg --name trivia-app -e VIRTUAL_HOST=trivia.ralreegorganon.com trivia-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) GetAllTrivia

func (db *DB) GetAllTrivia() ([]*Trivia, error)

func (*DB) GetRandomTrivia

func (db *DB) GetRandomTrivia() (*Trivia, error)

func (*DB) GetTrivia

func (db *DB) GetTrivia(id int64) (*Trivia, error)

func (*DB) Open

func (db *DB) Open() error

type HTTPServer

type HTTPServer struct {
	DB *DB
}

func NewHTTPServer

func NewHTTPServer(db *DB) *HTTPServer

func (*HTTPServer) GetAllTrivia

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

func (*HTTPServer) GetRandomTrivia

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

func (*HTTPServer) GetTrivia

func (s *HTTPServer) GetTrivia(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 Trivia

type Trivia struct {
	Id       int64  `json:"id" db:"trivia_id"`
	Question string `json:"question"`
	Answer   string `json:"answer"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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