first working version

This commit is contained in:
ston1th 2019-04-28 18:16:40 +02:00
commit de359ab415
47 changed files with 1016 additions and 2012 deletions

View file

@ -2,6 +2,8 @@
package server
import "git.giftfish.de/ston1th/docstore/pkg/core"
type route struct {
Path string
Handler ctxHandler
@ -10,90 +12,106 @@ type route struct {
var static = []route{
{
"/favicon.ico",
core.Favicon,
staticHandler,
[]string{"GET"},
},
{
"/bootstrap.css",
core.BootstrapCSS,
staticHandler,
[]string{"GET"},
},
{
"/custom.css",
core.CustomCSS,
staticHandler,
[]string{"GET"},
},
}
var register = append(static, route{
"/",
registerHandler,
var registerRoutes = append(static, route{
core.IndexURI,
jwtRegisterHandler(
registerHandler),
[]string{"GET", "POST"},
})
var prefixRoutes = []route{
{
core.RawPrefix,
jwtHandler(
authHandler(
fileHandler)),
[]string{"GET"},
},
{
core.IndexPrefix,
jwtHandler(
authHandler(
indexHandler)),
[]string{"GET", "POST"},
},
{
core.MovePrefix,
jwtHandler(
authHandler(
moveHandler)),
[]string{"GET", "POST"},
},
{
core.DeletePrefix,
jwtHandler(
authHandler(
deleteHandler)),
[]string{"GET", "POST"},
},
{
core.IndexURI,
jwtHandler(
authHandler(
dirHandler)),
[]string{"GET", "POST", "PUT", "DELETE"},
},
}
var routes = append(static, []route{
{
"/",
authHandler(
dirHandler),
[]string{"GET"},
},
{
"/sections",
sectionsHandler,
[]string{"GET"},
},
{
"/search",
authHandler(
searchHandler),
jwtHandler(
authHandler(
searchHandler)),
[]string{"GET", "POST"},
},
{
"/upload",
authHandler(
searchHandler),
core.LoginURI,
jwtHandler(
loginHandler),
[]string{"GET", "POST"},
},
{
"/login",
loginHandler,
core.TotpURI,
jwtHandler(
totpAuthHandler(
loginTotpHandler)),
[]string{"GET", "POST"},
},
{
"/totp",
totpAuthHandler(
loginTotpHandler),
"/user/edit",
jwtHandler(
authHandler(
userEditHandler)),
[]string{"GET", "POST"},
},
{
"/user/edit/{user:[a-zA-Z0-9]+$}",
authHandler(
userEditHandler),
"/user/totp",
jwtHandler(
authHandler(
userTotpHandler)),
[]string{"GET", "POST"},
},
{
"/user/totp/{user:[a-zA-Z0-9]+$}",
authHandler(
userTotpHandler),
core.LogoutURI,
jwtHandler(
logoutHandler),
[]string{"GET", "POST"},
},
{
"/logout",
logoutHandler,
[]string{"GET", "POST"},
},
{
"/{dir}",
authHandler(
dirHandler),
[]string{"GET"},
},
{
"/{dir}/{file}",
authHandler(
fileHandler),
[]string{"GET"},
},
}...)