package server

import (
	"fmt"
	"net/http"
)

func (s *Server) Routes() error {
	endpoints := []struct {
		path    string
		handler http.HandlerFunc
	}{
		{
			path:    fmt.Sprintf("authorize"),
			handler: s.authorize,
		},
		{
			path:    fmt.Sprintf("verify"),
			handler: s.verify,
		},
		{
			path:    fmt.Sprintf("users/log"),
			handler: s.usersLog,
		},
		{
			path:    fmt.Sprintf("users/register"),
			handler: s.usersRegister,
		},
		{
			path:    fmt.Sprintf("users/submit"),
			handler: s.usersSubmit,
		},
	}

	for _, endpoint := range endpoints {
		if err := s.Add(endpoint.path, endpoint.handler); err != nil {
			return err
		}
	}
	return nil
}
