Skip to content

Commit 0b35219

Browse files
committed
user database and glide
1 parent c982b17 commit 0b35219

File tree

436 files changed

+324802
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

436 files changed

+324802
-2
lines changed

cmd/web/handlers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,23 @@ func DisableIndex(next http.Handler) http.Handler {
113113
next.ServeHTTP(w, r)
114114
})
115115
}
116+
117+
func (app *App) SignupUser(w http.ResponseWriter, r *http.Request) {
118+
fmt.Fprint(w, "SignupUser")
119+
}
120+
121+
func (app *App) CreateUser(w http.ResponseWriter, r *http.Request) {
122+
fmt.Fprint(w, "CreateUser")
123+
}
124+
125+
func (app *App) LoginUser(w http.ResponseWriter, r *http.Request) {
126+
fmt.Fprint(w, "LoginUser")
127+
}
128+
129+
func (app *App) VerifyUser(w http.ResponseWriter, r *http.Request) {
130+
fmt.Fprint(w, "VerifyUser")
131+
}
132+
133+
func (app *App) LogoutUser(w http.ResponseWriter, r *http.Request) {
134+
fmt.Fprint(w, "LogoutUser")
135+
}

cmd/web/routes.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ func (app *App) Routes() http.Handler {
1111
mux := pat.New()
1212

1313
mux.Get("/", http.HandlerFunc(app.Home))
14+
1415
mux.Get("/snippet/new", http.HandlerFunc(app.NewSnippet))
1516
mux.Post("/snippet/new", http.HandlerFunc(app.CreateSnippet))
1617
mux.Get("/snippet/:id", http.HandlerFunc(app.ShowSnippet))
1718

19+
mux.Get("/user/signup", http.HandlerFunc(app.SignupUser))
20+
mux.Post("/user/signup", http.HandlerFunc(app.CreateUser))
21+
mux.Get("/user/login", http.HandlerFunc(app.LoginUser))
22+
mux.Post("/user/login", http.HandlerFunc(app.VerifyUser))
23+
mux.Post("/user/logout", http.HandlerFunc(app.LogoutUser))
24+
1825
fileServer := http.FileServer(http.Dir(app.staticDir))
1926
mux.Get("/static/", http.StripPrefix("/static", DisableIndex(fileServer)))
2027

glide.lock

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package: snippetbox.org
2+
import:
3+
- package: github.com/alexedwards/scs
4+
version: v1.3.0
5+
- package: github.com/bmizerany/pat
6+
- package: github.com/justinas/alice
7+
- package: github.com/mattn/go-sqlite3
8+
version: v1.9.0
9+
- package: golang.org/x/crypto
10+
subpackages:
11+
- bcrypt

pkg/models/database.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ func (db *Database) InitializeDb() error {
9494
expires DATETIME NOT NULL
9595
);
9696
97-
CREATE INDEX idx_snippets_created ON snippets(created);
97+
CREATE INDEX idx_snippets_created ON snippets(created);
98+
99+
CREATE TABLE users (
100+
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
101+
name VARCHAR(255) NOT NULL,
102+
email VARCHAR(255) NOT NULL UNIQUE,
103+
password CHAR(60) NOT NULL,
104+
created DATETIME NOT NULL
105+
);
98106
`
99107

100108
_, err = tx.Exec(stmt)

schema.sql

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,12 @@ CREATE TABLE snippets (
66
expires DATETIME NOT NULL
77
);
88

9-
CREATE INDEX idx_snippets_created ON snippets(created);
9+
CREATE INDEX idx_snippets_created ON snippets(created);
10+
11+
CREATE TABLE users (
12+
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
13+
name VARCHAR(255) NOT NULL,
14+
email VARCHAR(255) NOT NULL UNIQUE,
15+
password CHAR(60) NOT NULL,
16+
created DATETIME NOT NULL
17+
);

vendor/github.com/alexedwards/scs/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/alexedwards/scs/README.md

Lines changed: 126 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)