Documentation
¶
Overview ¶
Package gitlabfake is a fake of the repository files API of GitLab for the tests of the gitlab flag source: the raw files of one branch of one project, served as GitLab serves them (the project and the file path are each one path segment with "/" sent as %2F, a 404 for a file or a project that is not there, a 401 for a wrong token, a 404 for a private project without a token, the PRIVATE-TOKEN header, the rate limit answers with the RateLimit-* headers), and a record of what the relay sent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Request ¶
type Request struct {
// Project and File are the slug and the file path, decoded from their segments.
Project string
File string
// Ref is the ref query of the request.
Ref string
// Token is the PRIVATE-TOKEN header.
Token string
// URI is the request line target as it was sent, to show the encoding of the segments.
URI string
}
Request is what one request carried.
type Server ¶
Server is an http.Handler for /<prefix>/api/v4/projects/<slug>/repository/files/<path>/raw?ref=<branch>. The files are served by the embedded httpfake.Server (Put, Delete, Redirect and Counts).
func New ¶
func New(prefix, slug, branch string, validators httpfake.Validators) *Server
New returns a server for the project slug (group/project) and the branch. prefix is the path of GitLab below the host: empty for gitlab.com, for example /gitlab for a self-managed instance. validators is what the files send.
func (*Server) RequireToken ¶
RequireToken makes the project private: a request without a token is answered 404 and one with another token 401. Empty makes the project public.
func (*Server) ServeHTTP ¶
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler.