50 lines
997 B
Go
Executable File
50 lines
997 B
Go
Executable File
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"gitea.inhome.blapointe.com/local/oauth2/oauth2server/config"
|
|
"gitea.inhome.blapointe.com/local/router"
|
|
"net/http"
|
|
)
|
|
|
|
func (s *Server) Routes() error {
|
|
endpoints := []struct {
|
|
skip bool
|
|
path string
|
|
handler http.HandlerFunc
|
|
}{
|
|
{
|
|
path: fmt.Sprintf("authorize/%s", router.Wildcard),
|
|
handler: s.authorize,
|
|
},
|
|
{
|
|
path: fmt.Sprintf("verify/%s", router.Wildcard),
|
|
handler: s.verify,
|
|
},
|
|
{
|
|
path: fmt.Sprintf("users/log/%s", router.Wildcard),
|
|
handler: s.usersLog,
|
|
},
|
|
{
|
|
skip: !config.UserRegistration,
|
|
path: fmt.Sprintf("users/register/%s", router.Wildcard),
|
|
handler: s.usersRegister,
|
|
},
|
|
{
|
|
skip: !config.UserRegistration,
|
|
path: fmt.Sprintf("users/submit/%s", router.Wildcard),
|
|
handler: s.usersSubmit,
|
|
},
|
|
}
|
|
|
|
for _, endpoint := range endpoints {
|
|
if endpoint.skip {
|
|
continue
|
|
}
|
|
if err := s.Add(endpoint.path, endpoint.handler); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|