s/backend/middleware

This commit is contained in:
Jimmy Zelinskie 2016-08-09 20:08:15 -04:00
commit c9fe95b103
7 changed files with 142 additions and 169 deletions
middleware

24
middleware/hooks.go Normal file
View file

@ -0,0 +1,24 @@
package middleware
import (
"golang.org/x/net/context"
"github.com/jzelinskie/trakr/bittorrent"
)
// Hook abstracts the concept of anything that needs to interact with a
// BitTorrent client's request and response to a BitTorrent tracker.
type Hook interface {
HandleAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse) error
HandleScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse) error
}
type nopHook struct{}
func (nopHook) HandleAnnounce(context.Context, *bittorrent.AnnounceRequest, *bittorrent.AnnounceResponse) error {
return nil
}
func (nopHook) HandleScrape(context.Context, *bittorrent.ScrapeRequest, *bittorrent.ScrapeResponse) error {
return nil
}