33 lines
538 B
Go
Executable File
33 lines
538 B
Go
Executable File
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)
|
|
}
|
|
}
|