- added follow command - added unfollow command - following command - introduced logged in user middleware
21 lines
412 B
Go
21 lines
412 B
Go
package command
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/StevanFreeborn/gator/internal/database"
|
|
"github.com/StevanFreeborn/gator/internal/state"
|
|
)
|
|
|
|
func requiresLoggedInUser(handler func(*state.State, database.User) error) CommandHandler {
|
|
return func(s *state.State) error {
|
|
loggedInUser, err := s.GetCurrentUser(context.Background())
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return handler(s, loggedInUser)
|
|
}
|
|
}
|