Base project to template

This commit is contained in:
bel
2020-03-12 13:48:04 -06:00
commit f022b26987
19 changed files with 543 additions and 0 deletions

32
server/server.go Executable file
View File

@@ -0,0 +1,32 @@
package server
import (
"local/firestormy/config"
"local/oauth2/oauth2client"
"local/router"
"log"
"net/http"
)
type Server struct {
*router.Router
}
func New() *Server {
return &Server{
Router: router.New(),
}
}
func (s *Server) authenticate(foo http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if config.OAuthServer != "" {
err := oauth2client.Authenticate(config.OAuthServer, "firestormy", w, r)
if err != nil {
log.Println(err)
return
}
}
foo(w, r)
}
}