Browse Source

rename controllers in handler

cleanup
Lars Hoogestraat 1 month ago
parent
commit
95834ef9f1
21 changed files with 141 additions and 141 deletions
  1. +1
    -1
      handler/account.go
  2. +5
    -5
      handler/account_test.go
  3. +1
    -1
      handler/article.go
  4. +10
    -10
      handler/article_test.go
  5. +1
    -1
      handler/category.go
  6. +7
    -7
      handler/category_test.go
  7. +1
    -1
      handler/const.go
  8. +1
    -1
      handler/file.go
  9. +6
    -6
      handler/file_test.go
  10. +1
    -1
      handler/form_util.go
  11. +1
    -1
      handler/login.go
  12. +3
    -3
      handler/login_test.go
  13. +1
    -1
      handler/site.go
  14. +10
    -10
      handler/site_test.go
  15. +0
    -0
      handler/testdata/color.png
  16. +1
    -1
      handler/user.go
  17. +1
    -1
      handler/user_invite.go
  18. +5
    -5
      handler/user_invite_test.go
  19. +6
    -6
      handler/user_test.go
  20. +1
    -1
      handler/utils_test.go
  21. +78
    -78
      routers/router.go

controllers/account.go → handler/account.go View File

@ -1,4 +1,4 @@
package controllers
package handler
import (
"bytes"

controllers/account_test.go → handler/account_test.go View File

@ -1,11 +1,11 @@
package controllers_test
package handler_test
import (
"net/http/httptest"
"net/url"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -94,7 +94,7 @@ func doAdminProfileRequest(user reqUser, u *models.User, currentPassword string)
rw := httptest.NewRecorder()
re := r.buildRequest()
tpl := controllers.AdminProfilePostHandler(ctx, rw, re)
tpl := handler.AdminProfilePostHandler(ctx, rw, re)
if tpl.Err != nil {
return tpl.Err
@ -122,7 +122,7 @@ func doActivateAccountRequest(user reqUser, password, passwordRepeat, hash strin
}
rw := httptest.NewRecorder()
tpl := controllers.ActivateAccountPostHandler(ctx, rw, r.buildRequest())
tpl := handler.ActivateAccountPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -150,7 +150,7 @@ func doResetPasswordRequest(user reqUser, password, passwordRepeat, hash string)
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSiteEditPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSiteEditPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/article.go → handler/article.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"database/sql"

controllers/article_test.go → handler/article_test.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers_test
package handler_test
import (
"fmt"
@ -13,7 +13,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -143,7 +143,7 @@ func doGetArticleBySlugRequest(user reqUser, article *models.Article) (*models.A
}
rw := httptest.NewRecorder()
tpl := controllers.GetArticleHandler(ctx, rw, r.buildRequest())
tpl := handler.GetArticleHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -166,7 +166,7 @@ func doGetArticleByIDRequest(user reqUser, articleID int) (*models.Article, erro
}
rw := httptest.NewRecorder()
tpl := controllers.GetArticleByIDHandler(ctx, rw, r.buildRequest())
tpl := handler.GetArticleByIDHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -196,7 +196,7 @@ func doAdminEditArticleRequest(user reqUser, articleID int, article *models.Arti
rw := httptest.NewRecorder()
tpl := controllers.AdminArticleEditPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminArticleEditPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -222,7 +222,7 @@ func doAdminCreateArticleRequest(user reqUser, article *models.Article) (int, er
}
rw := httptest.NewRecorder()
tpl := controllers.AdminArticleNewPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminArticleNewPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return 0, tpl.Err
@ -249,7 +249,7 @@ func doAdminGetArticleByIDRequest(user reqUser, articleID int) (*models.Article,
}
rw := httptest.NewRecorder()
tpl := controllers.AdminPreviewArticleByIDHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminPreviewArticleByIDHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -266,7 +266,7 @@ func doAdminListArticleRequest(user reqUser) ([]models.Article, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminListArticlesHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminListArticlesHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -289,7 +289,7 @@ func doAdminPublishArticleRequest(user reqUser, articleID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminArticlePublishPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminArticlePublishPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -312,7 +312,7 @@ func doAdminRemoveArticleRequest(user reqUser, articleID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminArticleDeletePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminArticleDeletePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/category.go → handler/category.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"fmt"

controllers/category_test.go → handler/category_test.go View File

@ -1,4 +1,4 @@
package controllers_test
package handler_test
import (
"net/http/httptest"
@ -6,7 +6,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -82,7 +82,7 @@ func doAdminGetCategoryRequest(user reqUser, categoryID int) (*models.Category,
}
rw := httptest.NewRecorder()
tpl := controllers.AdminGetCategoryHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminGetCategoryHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -99,7 +99,7 @@ func doAdminListCategoriesRequest(user reqUser) ([]models.Category, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminListCategoriesHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminListCategoriesHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -119,7 +119,7 @@ func doAdminCategoryNewRequest(user reqUser, c *models.Category) (int, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminCategoryNewPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminCategoryNewPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return -1, tpl.Err
@ -144,7 +144,7 @@ func doAdminCategoryEditRequest(user reqUser, c *models.Category) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminCategoryEditPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminCategoryEditPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -166,7 +166,7 @@ func doAdminDeleteCategoryRequest(user reqUser, categoryID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminCategoryDeletePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminCategoryDeletePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/const.go → handler/const.go View File

@ -1,4 +1,4 @@
package controllers
package handler
const (
tplArticle = "front/article"

controllers/file.go → handler/file.go View File

@ -1,4 +1,4 @@
package controllers
package handler
import (
"errors"

controllers/file_test.go → handler/file_test.go View File

@ -1,4 +1,4 @@
package controllers_test
package handler_test
import (
"fmt"
@ -7,7 +7,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -63,7 +63,7 @@ func doAdminListFilesRequest(user reqUser) ([]models.File, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminListFilesHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminListFilesHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -87,7 +87,7 @@ func doAdminGetFileRequest(user reqUser, uniquename string) (*httptest.ResponseR
rw := httptest.NewRecorder()
fh := controllers.FileHandler{
fh := handler.FileHandler{
Context: ctx,
}
@ -116,7 +116,7 @@ func doAdminUploadFileRequest(user reqUser, file string) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUploadFilePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUploadFilePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -139,7 +139,7 @@ func doAdminFileDeleteRequest(user reqUser, fileID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUploadDeletePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUploadDeletePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/form_util.go → handler/form_util.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"net/http"

controllers/login.go → handler/login.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"net/http"

controllers/login_test.go → handler/login_test.go View File

@ -1,4 +1,4 @@
package controllers_test
package handler_test
import (
"fmt"
@ -6,7 +6,7 @@ import (
"net/url"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
)
func TestLogin(t *testing.T) {
@ -71,7 +71,7 @@ func doLoginRequest(user reqUser, login, password string) (responseWrapper, erro
}
rr := httptest.NewRecorder()
tpl := controllers.LoginPostHandler(ctx, rr, r.buildRequest())
tpl := handler.LoginPostHandler(ctx, rr, r.buildRequest())
if tpl.Err != nil {
return responseWrapper{response: rr, template: tpl}, tpl.Err

controllers/site.go → handler/site.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"database/sql"

controllers/site_test.go → handler/site_test.go View File

@ -1,4 +1,4 @@
package controllers_test
package handler_test
import (
"fmt"
@ -7,7 +7,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -92,7 +92,7 @@ func doGetSiteRequest(user reqUser, link string) (*models.Site, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.GetSiteHandler(ctx, rw, r.buildRequest())
tpl := handler.GetSiteHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -115,7 +115,7 @@ func doAdminGetSiteRequest(user reqUser, siteID int) (*models.Site, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminGetSiteHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminGetSiteHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -132,7 +132,7 @@ func doAdminListSitesRequest(user reqUser) ([]models.Site, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSitesHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSitesHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -156,7 +156,7 @@ func doAdminSiteCreateRequest(user reqUser, s *models.Site) (int, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSiteNewPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSiteNewPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return 0, tpl.Err
@ -185,7 +185,7 @@ func doAdminSitePublishRequest(user reqUser, siteID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSitePublishPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSitePublishPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -215,7 +215,7 @@ func doAdminSiteEditRequest(user reqUser, s *models.Site) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSiteEditPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSiteEditPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -238,7 +238,7 @@ func doAdminSiteDeleteRequest(user reqUser, siteID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSiteDeletePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSiteDeletePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -261,7 +261,7 @@ func doAdminSiteOrderRequest(user reqUser, siteID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminSiteOrderHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminSiteOrderHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/testdata/color.png → handler/testdata/color.png View File


controllers/user.go → handler/user.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers
package handler
import (
"fmt"

controllers/user_invite.go → handler/user_invite.go View File

@ -1,4 +1,4 @@
package controllers
package handler
import (
"fmt"

controllers/user_invite_test.go → handler/user_invite_test.go View File

@ -1,4 +1,4 @@
package controllers_test
package handler_test
import (
"net/http/httptest"
@ -6,7 +6,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -70,7 +70,7 @@ func doAdminCreateUserInviteRequest(user reqUser, ui *models.UserInvite) (int, s
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserInviteNewPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserInviteNewPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return -1, "", tpl.Err
@ -93,7 +93,7 @@ func doAdminResendUserInviteRequest(user reqUser, inviteID int) (int, string, er
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserInviteResendPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserInviteResendPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return -1, "", tpl.Err
@ -116,7 +116,7 @@ func doAdminRemoveUserInviteRequest(user reqUser, inviteID int) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserInviteDeletePostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserInviteDeletePostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err

controllers/user_test.go → handler/user_test.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers_test
package handler_test
import (
"fmt"
@ -11,7 +11,7 @@ import (
"strconv"
"testing"
"git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
"git.hoogi.eu/snafu/go-blog/models"
)
@ -110,7 +110,7 @@ func doAdminGetUserRequest(user reqUser, userID int) (*models.User, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserEditHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserEditHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -156,7 +156,7 @@ func doAdminEditUsersRequest(user reqUser, u *models.User) error {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserEditPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserEditPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return tpl.Err
@ -176,7 +176,7 @@ func doAdminListUsersRequest(user reqUser) ([]models.User, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUsersHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUsersHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return nil, tpl.Err
@ -202,7 +202,7 @@ func doAdminCreateUserRequest(user reqUser, u *models.User) (int, error) {
}
rw := httptest.NewRecorder()
tpl := controllers.AdminUserNewPostHandler(ctx, rw, r.buildRequest())
tpl := handler.AdminUserNewPostHandler(ctx, rw, r.buildRequest())
if tpl.Err != nil {
return 0, tpl.Err

controllers/utils_test.go → handler/utils_test.go View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package controllers_test
package handler_test
import (
"bytes"

+ 78
- 78
routers/router.go View File

@ -8,7 +8,7 @@ import (
"net/http"
"os"
c "git.hoogi.eu/snafu/go-blog/controllers"
"git.hoogi.eu/snafu/go-blog/handler"
m "git.hoogi.eu/snafu/go-blog/middleware"
"git.hoogi.eu/snafu/go-blog/settings"
@ -90,108 +90,108 @@ func fileLoggingHandler(accessLogPath string) (flh func(http.Handler) http.Handl
func restrictedRoutes(ctx *m.AppContext, router *mux.Router, chain alice.Chain) {
//article
router.Handle("/articles", chain.Then(useTemplateHandler(ctx, c.AdminListArticlesHandler))).Methods("GET")
router.Handle("/articles/page/{page}", chain.Then(useTemplateHandler(ctx, c.AdminListArticlesHandler))).Methods("GET")
router.Handle("/article/new", chain.Then(useTemplateHandler(ctx, c.AdminArticleNewHandler))).Methods("GET")
router.Handle("/article/new", chain.Then(useTemplateHandler(ctx, c.AdminArticleNewPostHandler))).Methods("POST")
router.Handle("/article/edit/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticleEditHandler))).Methods("GET")
router.Handle("/article/edit/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticleEditPostHandler))).Methods("POST")
router.Handle("/article/publish/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticlePublishHandler))).Methods("GET")
router.Handle("/article/publish/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticlePublishPostHandler))).Methods("POST")
router.Handle("/article/delete/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticleDeleteHandler))).Methods("GET")
router.Handle("/article/delete/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminArticleDeletePostHandler))).Methods("POST")
router.Handle("/article/{articleID}", chain.Then(useTemplateHandler(ctx, c.AdminPreviewArticleByIDHandler))).Methods("GET")
router.Handle("/articles", chain.Then(useTemplateHandler(ctx, handler.AdminListArticlesHandler))).Methods("GET")
router.Handle("/articles/page/{page}", chain.Then(useTemplateHandler(ctx, handler.AdminListArticlesHandler))).Methods("GET")
router.Handle("/article/new", chain.Then(useTemplateHandler(ctx, handler.AdminArticleNewHandler))).Methods("GET")
router.Handle("/article/new", chain.Then(useTemplateHandler(ctx, handler.AdminArticleNewPostHandler))).Methods("POST")
router.Handle("/article/edit/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticleEditHandler))).Methods("GET")
router.Handle("/article/edit/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticleEditPostHandler))).Methods("POST")
router.Handle("/article/publish/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticlePublishHandler))).Methods("GET")
router.Handle("/article/publish/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticlePublishPostHandler))).Methods("POST")
router.Handle("/article/delete/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticleDeleteHandler))).Methods("GET")
router.Handle("/article/delete/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminArticleDeletePostHandler))).Methods("POST")
router.Handle("/article/{articleID}", chain.Then(useTemplateHandler(ctx, handler.AdminPreviewArticleByIDHandler))).Methods("GET")
//user
router.Handle("/user/profile", chain.Then(useTemplateHandler(ctx, c.AdminProfileHandler))).Methods("GET")
router.Handle("/user/profile", chain.Then(useTemplateHandler(ctx, c.AdminProfilePostHandler))).Methods("POST")
router.Handle("/users", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUsersHandler))).Methods("GET")
router.Handle("/users/page/{page}", chain.Then(useTemplateHandler(ctx, c.AdminUsersHandler))).Methods("GET")
router.Handle("/user/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserNewHandler))).Methods("GET")
router.Handle("/user/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserNewPostHandler))).Methods("POST")
router.Handle("/user/edit/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserEditHandler))).Methods("GET")
router.Handle("/user/edit/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserEditPostHandler))).Methods("POST")
router.Handle("/user/delete/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserDeleteHandler))).Methods("GET")
router.Handle("/user/delete/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserDeletePostHandler))).Methods("POST")
router.Handle("/user/profile", chain.Then(useTemplateHandler(ctx, handler.AdminProfileHandler))).Methods("GET")
router.Handle("/user/profile", chain.Then(useTemplateHandler(ctx, handler.AdminProfilePostHandler))).Methods("POST")
router.Handle("/users", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUsersHandler))).Methods("GET")
router.Handle("/users/page/{page}", chain.Then(useTemplateHandler(ctx, handler.AdminUsersHandler))).Methods("GET")
router.Handle("/user/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserNewHandler))).Methods("GET")
router.Handle("/user/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserNewPostHandler))).Methods("POST")
router.Handle("/user/edit/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserEditHandler))).Methods("GET")
router.Handle("/user/edit/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserEditPostHandler))).Methods("POST")
router.Handle("/user/delete/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserDeleteHandler))).Methods("GET")
router.Handle("/user/delete/{userID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserDeletePostHandler))).Methods("POST")
//user invites
router.Handle("/user-invite/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserInviteNewHandler))).Methods("GET")
router.Handle("/user-invite/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserInviteNewPostHandler))).Methods("POST")
router.Handle("/user-invite/resend/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserInviteResendPostHandler))).Methods("POST")
router.Handle("/user-invite/delete/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserInviteDeleteHandler))).Methods("GET")
router.Handle("/user-invite/delete/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminUserInviteDeletePostHandler))).Methods("POST")
router.Handle("/user-invite/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserInviteNewHandler))).Methods("GET")
router.Handle("/user-invite/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserInviteNewPostHandler))).Methods("POST")
router.Handle("/user-invite/resend/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserInviteResendPostHandler))).Methods("POST")
router.Handle("/user-invite/delete/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserInviteDeleteHandler))).Methods("GET")
router.Handle("/user-invite/delete/{inviteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminUserInviteDeletePostHandler))).Methods("POST")
//site
router.Handle("/sites", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSitesHandler))).Methods("GET")
router.Handle("/site/page/{page}", chain.Then(useTemplateHandler(ctx, c.AdminSitesHandler))).Methods("GET")
router.Handle("/site/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteNewHandler))).Methods("GET")
router.Handle("/site/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteNewPostHandler))).Methods("POST")
router.Handle("/site/publish/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSitePublishHandler))).Methods("GET")
router.Handle("/site/publish/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSitePublishPostHandler))).Methods("POST")
router.Handle("/site/edit/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteEditHandler))).Methods("GET")
router.Handle("/site/edit/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteEditPostHandler))).Methods("POST")
router.Handle("/site/delete/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteDeleteHandler))).Methods("GET")
router.Handle("/site/delete/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteDeletePostHandler))).Methods("POST")
router.Handle("/site/order/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, c.AdminSiteOrderHandler))).Methods("POST")
router.Handle("/site/{siteID:[0-9]+}}", chain.Then(useTemplateHandler(ctx, c.AdminGetSiteHandler))).Methods("GET")
router.Handle("/sites", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSitesHandler))).Methods("GET")
router.Handle("/site/page/{page}", chain.Then(useTemplateHandler(ctx, handler.AdminSitesHandler))).Methods("GET")
router.Handle("/site/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteNewHandler))).Methods("GET")
router.Handle("/site/new", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteNewPostHandler))).Methods("POST")
router.Handle("/site/publish/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSitePublishHandler))).Methods("GET")
router.Handle("/site/publish/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSitePublishPostHandler))).Methods("POST")
router.Handle("/site/edit/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteEditHandler))).Methods("GET")
router.Handle("/site/edit/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteEditPostHandler))).Methods("POST")
router.Handle("/site/delete/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteDeleteHandler))).Methods("GET")
router.Handle("/site/delete/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteDeletePostHandler))).Methods("POST")
router.Handle("/site/order/{siteID}", chain.Append(ctx.RequireAdmin).Then(useTemplateHandler(ctx, handler.AdminSiteOrderHandler))).Methods("POST")
router.Handle("/site/{siteID:[0-9]+}}", chain.Then(useTemplateHandler(ctx, handler.AdminGetSiteHandler))).Methods("GET")
//article
router.Handle("/categories", chain.Then(useTemplateHandler(ctx, c.AdminListCategoriesHandler))).Methods("GET")
router.Handle("/category/{categoryID:[0-9]+}}", chain.Then(useTemplateHandler(ctx, c.AdminGetCategoryHandler))).Methods("POST")
router.Handle("/category/new", chain.Then(useTemplateHandler(ctx, c.AdminCategoryNewHandler))).Methods("GET")
router.Handle("/category/new", chain.Then(useTemplateHandler(ctx, c.AdminCategoryNewPostHandler))).Methods("POST")
router.Handle("/category/edit/{categoryID}", chain.Then(useTemplateHandler(ctx, c.AdminCategoryEditHandler))).Methods("GET")
router.Handle("/category/edit/{categoryID}", chain.Then(useTemplateHandler(ctx, c.AdminCategoryEditPostHandler))).Methods("POST")
router.Handle("/category/delete/{categoryID}", chain.Then(useTemplateHandler(ctx, c.AdminCategoryDeleteHandler))).Methods("GET")
router.Handle("/category/delete/{categoryID}", chain.Then(useTemplateHandler(ctx, c.AdminCategoryDeletePostHandler))).Methods("POST")
router.Handle("/categories", chain.Then(useTemplateHandler(ctx, handler.AdminListCategoriesHandler))).Methods("GET")
router.Handle("/category/{categoryID:[0-9]+}}", chain.Then(useTemplateHandler(ctx, handler.AdminGetCategoryHandler))).Methods("POST")
router.Handle("/category/new", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryNewHandler))).Methods("GET")
router.Handle("/category/new", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryNewPostHandler))).Methods("POST")
router.Handle("/category/edit/{categoryID}", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryEditHandler))).Methods("GET")
router.Handle("/category/edit/{categoryID}", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryEditPostHandler))).Methods("POST")
router.Handle("/category/delete/{categoryID}", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryDeleteHandler))).Methods("GET")
router.Handle("/category/delete/{categoryID}", chain.Then(useTemplateHandler(ctx, handler.AdminCategoryDeletePostHandler))).Methods("POST")
//file
router.Handle("/files", chain.Then(useTemplateHandler(ctx, c.AdminListFilesHandler))).Methods("GET")
router.Handle("/files/page/{page}", chain.Then(useTemplateHandler(ctx, c.AdminListFilesHandler))).Methods("GET")
router.Handle("/file/upload", chain.Then(useTemplateHandler(ctx, c.AdminUploadFileHandler))).Methods("GET")
router.Handle("/file/upload", chain.Then(useTemplateHandler(ctx, c.AdminUploadFilePostHandler))).Methods("POST")
router.Handle("/file/toggleInline/{fileID}", chain.Then(useTemplateHandler(ctx, c.AdminToggleInlineFilePostHandler))).Methods("POST")
router.Handle("/file/delete/{fileID}", chain.Then(useTemplateHandler(ctx, c.AdminUploadDeleteHandler))).Methods("GET")
router.Handle("/file/delete/{fileID}", chain.Then(useTemplateHandler(ctx, c.AdminUploadDeletePostHandler))).Methods("POST")
router.Handle("/logout", chain.Then(useTemplateHandler(ctx, c.LogoutHandler))).Methods("GET")
router.Handle("/json/session/keep-alive", chain.Then(useJSONHandler(ctx, c.KeepAliveSessionHandler))).Methods("POST")
router.Handle("/json/file/upload", chain.Then(useJSONHandler(ctx, c.AdminUploadJSONFilePostHandler))).Methods("POST")
router.Handle("/files", chain.Then(useTemplateHandler(ctx, handler.AdminListFilesHandler))).Methods("GET")
router.Handle("/files/page/{page}", chain.Then(useTemplateHandler(ctx, handler.AdminListFilesHandler))).Methods("GET")
router.Handle("/file/upload", chain.Then(useTemplateHandler(ctx, handler.AdminUploadFileHandler))).Methods("GET")
router.Handle("/file/upload", chain.Then(useTemplateHandler(ctx, handler.AdminUploadFilePostHandler))).Methods("POST")
router.Handle("/file/toggleInline/{fileID}", chain.Then(useTemplateHandler(ctx, handler.AdminToggleInlineFilePostHandler))).Methods("POST")
router.Handle("/file/delete/{fileID}", chain.Then(useTemplateHandler(ctx, handler.AdminUploadDeleteHandler))).Methods("GET")
router.Handle("/file/delete/{fileID}", chain.Then(useTemplateHandler(ctx, handler.AdminUploadDeletePostHandler))).Methods("POST")
router.Handle("/logout", chain.Then(useTemplateHandler(ctx, handler.LogoutHandler))).Methods("GET")
router.Handle("/json/session/keep-alive", chain.Then(useJSONHandler(ctx, handler.KeepAliveSessionHandler))).Methods("POST")
router.Handle("/json/file/upload", chain.Then(useJSONHandler(ctx, handler.AdminUploadJSONFilePostHandler))).Methods("POST")
}
func publicRoutes(ctx *m.AppContext, router *mux.Router, chain alice.Chain) {
fh := c.FileHandler{
fh := handler.FileHandler{
Context: ctx,
}
router.Handle("/", chain.Then(useTemplateHandler(ctx, c.ListArticlesHandler))).Methods("GET")
router.Handle("/articles/category/{categorySlug}", chain.Then(useTemplateHandler(ctx, c.ListArticlesCategoryHandler))).Methods("GET")
router.Handle("/articles/category/{categorySlug}/{page}", chain.Then(useTemplateHandler(ctx, c.ListArticlesCategoryHandler))).Methods("GET")
router.Handle("/index", chain.Then(useTemplateHandler(ctx, c.IndexArticlesHandler))).Methods("GET")
router.Handle("/index/category/{categorySlug}", chain.Then(useTemplateHandler(ctx, c.IndexArticlesCategoryHandler))).Methods("GET")
router.Handle("/", chain.Then(useTemplateHandler(ctx, handler.ListArticlesHandler))).Methods("GET")
router.Handle("/articles/category/{categorySlug}", chain.Then(useTemplateHandler(ctx, handler.ListArticlesCategoryHandler))).Methods("GET")
router.Handle("/articles/category/{categorySlug}/{page}", chain.Then(useTemplateHandler(ctx, handler.ListArticlesCategoryHandler))).Methods("GET")
router.Handle("/index", chain.Then(useTemplateHandler(ctx, handler.IndexArticlesHandler))).Methods("GET")
router.Handle("/index/category/{categorySlug}", chain.Then(useTemplateHandler(ctx, handler.IndexArticlesCategoryHandler))).Methods("GET")
router.Handle("/articles/page/{page}", chain.Then(useTemplateHandler(ctx, c.ListArticlesHandler))).Methods("GET")
router.Handle("/article/{year}/{month}/{slug}", chain.Then(useTemplateHandler(ctx, c.GetArticleHandler))).Methods("GET")
router.Handle("/article/by-id/{articleID}", chain.Then(useTemplateHandler(ctx, c.GetArticleByIDHandler))).Methods("GET")
router.Handle("/articles/page/{page}", chain.Then(useTemplateHandler(ctx, handler.ListArticlesHandler))).Methods("GET")
router.Handle("/article/{year}/{month}/{slug}", chain.Then(useTemplateHandler(ctx, handler.GetArticleHandler))).Methods("GET")
router.Handle("/article/by-id/{articleID}", chain.Then(useTemplateHandler(ctx, handler.GetArticleByIDHandler))).Methods("GET")
router.Handle("/rss.xml", chain.Then(useXMLHandler(ctx, c.RSSFeed))).Methods("GET")
router.Handle("/rss.xml", chain.Then(useXMLHandler(ctx, handler.RSSFeed))).Methods("GET")
router.Handle("/site/{site}", chain.Then(useTemplateHandler(ctx, c.GetSiteHandler))).Methods("GET")
router.Handle("/site/{site}", chain.Then(useTemplateHandler(ctx, handler.GetSiteHandler))).Methods("GET")
router.Handle("/file/{uniquename}", chain.ThenFunc(fh.FileGetHandler)).Methods("GET")
router.Handle("/admin", chain.Then(useTemplateHandler(ctx, c.LoginHandler))).Methods("GET")
router.Handle("/admin", chain.Then(useTemplateHandler(ctx, c.LoginPostHandler))).Methods("POST")
router.Handle("/admin", chain.Then(useTemplateHandler(ctx, handler.LoginHandler))).Methods("GET")
router.Handle("/admin", chain.Then(useTemplateHandler(ctx, handler.LoginPostHandler))).Methods("POST")
router.Handle("/admin/forgot-password", chain.Then(useTemplateHandler(ctx, c.ForgotPasswordHandler))).Methods("GET")
router.Handle("/admin/forgot-password", chain.Then(useTemplateHandler(ctx, c.ForgotPasswordPostHandler))).Methods("POST")
router.Handle("/admin/forgot-password", chain.Then(useTemplateHandler(ctx, handler.ForgotPasswordHandler))).Methods("GET")
router.Handle("/admin/forgot-password", chain.Then(useTemplateHandler(ctx, handler.ForgotPasswordPostHandler))).Methods("POST")
router.Handle("/admin/reset-password/{hash}", chain.Then(useTemplateHandler(ctx, c.ResetPasswordHandler))).Methods("GET")
router.Handle("/admin/reset-password/{hash}", chain.Then(useTemplateHandler(ctx, c.ResetPasswordPostHandler))).Methods("POST")
router.Handle("/admin/reset-password/{hash}", chain.Then(useTemplateHandler(ctx, handler.ResetPasswordHandler))).Methods("GET")
router.Handle("/admin/reset-password/{hash}", chain.Then(useTemplateHandler(ctx, handler.ResetPasswordPostHandler))).Methods("POST")
router.Handle("/admin/activate-account/{hash}", chain.Then(useTemplateHandler(ctx, c.ActivateAccountHandler))).Methods("GET")
router.Handle("/admin/activate-account/{hash}", chain.Then(useTemplateHandler(ctx, c.ActivateAccountPostHandler))).Methods("POST")
router.Handle("/admin/activate-account/{hash}", chain.Then(useTemplateHandler(ctx, handler.ActivateAccountHandler))).Methods("GET")
router.Handle("/admin/activate-account/{hash}", chain.Then(useTemplateHandler(ctx, handler.ActivateAccountPostHandler))).Methods("POST")
}
func useTemplateHandler(ctx *m.AppContext, handler m.Handler) m.TemplateHandler {


Loading…
Cancel
Save