-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (33 loc) · 1.28 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package abenga
import (
"net/http"
)
import (
"github.com/gorilla/context"
"github.com/gorilla/mux"
"github.com/justinas/alice"
)
import (
mw "middleware"
"views"
author "views/author"
)
func init() {
r := mux.NewRouter()
plainMid := alice.New(context.ClearHandler, mw.Initialize)
authMid := alice.New(context.ClearHandler, mw.Initialize, mw.CheckAuth)
// Viewable without login
r.Handle("/", plainMid.ThenFunc(views.Index))
r.Handle("/postseries/{seriesjtitle}/", plainMid.ThenFunc(views.PostSeries))
r.Handle("/post/{year}/{month}/{day}/{jtitle}/", plainMid.ThenFunc(views.Post))
r.Handle("/author/sign_in/", plainMid.ThenFunc(author.SignIn))
r.Handle("/author/sign_in_google_callback/", plainMid.ThenFunc(author.GoogleCallback))
// Author pages - viewable only by authorized author.
r.Handle("/author/", authMid.ThenFunc(author.Home))
r.Handle("/author/newpost/", authMid.ThenFunc(author.NewPost))
r.Handle("/author/newpostseries/", authMid.ThenFunc(author.NewPostSeries))
r.Handle("/author/postseries/{seriesjtitle}/newpost/", authMid.ThenFunc(author.NewPostInSeries))
r.Handle("/author/postseries/{seriesjtitle}/edit/", authMid.ThenFunc(author.EditSeries))
r.Handle("/author/post/{year}/{month}/{day}/{jtitle}/edit/", authMid.ThenFunc(author.EditPost))
http.Handle("/", r)
}