http

package
v0.0.0-...-befd6c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2015 License: BSD-2-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package http implements an http-serving BitTorrent tracker.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResponseHandler

type ResponseHandler func(http.ResponseWriter, *http.Request, httprouter.Params) (int, error)

ResponseHandler is an HTTP handler that returns a status code.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents an HTTP serving torrent tracker.

func NewServer

func NewServer(cfg *config.Config, tkr *tracker.Tracker) *Server

NewServer returns a new HTTP server for a given configuration and tracker.

func (*Server) Serve

func (s *Server) Serve(addr string)

Serve runs an HTTP server, blocking until the server has shut down.

func (*Server) Stop

func (s *Server) Stop()

Stop cleanly shuts down the server.

type Writer

type Writer struct {
	http.ResponseWriter
}

Writer implements the tracker.Writer interface for the HTTP protocol.

func (*Writer) WriteAnnounce

func (w *Writer) WriteAnnounce(res *models.AnnounceResponse) error

WriteAnnounce writes a bencode dict representation of an AnnounceResponse.

func (*Writer) WriteError

func (w *Writer) WriteError(err error) error

WriteError writes a bencode dict with a failure reason.

func (*Writer) WriteScrape

func (w *Writer) WriteScrape(res *models.ScrapeResponse) error

WriteScrape writes a bencode dict representation of a ScrapeResponse.

Directories

Path Synopsis
Package query implements a faster single-purpose URL Query parser.
Package query implements a faster single-purpose URL Query parser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL