Documentation
¶
Overview ¶
Package githubfake is a fake of the contents API of GitHub for the tests of the github flag source: the files of one branch of one repository, answered with an ETag and 304, a 404 for a file that is away, a token the server requires, the answers of an exhausted request limit, a redirect, and a record of what the relay sent (path, ref, token and Accept).
Index ¶
- type Request
- type Server
- func (s *Server) Counts() httpfake.Counts
- func (s *Server) Delete(path string)
- func (s *Server) Dir(path string)
- func (s *Server) Put(path string, data []byte)
- func (s *Server) Redirect(path, address string)
- func (s *Server) Requests() []Request
- func (s *Server) RequireToken(token string)
- func (s *Server) Secondary(seconds int)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Throttle(reset time.Time)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
// Path is the path of the file in the repository.
Path string
// Ref is the ref query of the request.
Ref string
// Authorization and Accept are the headers of the request.
Authorization string
Accept string
// RawQuery is the whole query, to show that nothing else is in it.
RawQuery string
}
Request is what one request carried.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an http.Handler for /<prefix>/repos/<slug>/contents/<path>?ref=<branch>.
func New ¶
New returns a server for the repository slug (owner/repo) and the branch. prefix is the path of the API below the host: empty for github.com, /api/v3 for GitHub Enterprise Server.
func (*Server) Counts ¶
Counts returns what the file server answered: requests, bodies and 304 answers.
func (*Server) Dir ¶
Dir makes the path a directory: the contents API answers a key that is a directory with the JSON listing, also when the raw media type was asked for.
func (*Server) RequireToken ¶
RequireToken makes the server answer 401 to a request that does not carry "Bearer <token>". Empty removes the rule.
func (*Server) Secondary ¶
Secondary makes the server answer every request with 403 and a Retry-After of that many seconds (the secondary limit of GitHub). Zero ends it.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.