Documentation ¶
Index ¶
- Constants
- Variables
- func EqualFold(s, t string) bool
- func GenerateJWT(u *database.User, rid int64, op protocol.Operation, expiresAt time.Time) (string, error)
- func JsonEncode(w http.ResponseWriter, a any)
- func Z1Matcher(r *http.Request, m *mux.RouteMatch) bool
- func ZetaEncodeVND(w http.ResponseWriter, a any)
- type BearerMD
- type HandlerFunc
- type NewKey
- type NewRepo
- type NewUser
- type Request
- type ResponseWriter
- type Server
- func (s *Server) BatchCheck(w http.ResponseWriter, r *Request)
- func (s *Server) BatchMetadata(w http.ResponseWriter, r *Request)
- func (s *Server) BatchObjects(w http.ResponseWriter, r *Request)
- func (s *Server) BranchPush(w http.ResponseWriter, r *Request, branchName string)
- func (s *Server) FetchMetadata(w http.ResponseWriter, r *Request)
- func (s *Server) GetObject(w http.ResponseWriter, r *Request)
- func (s *Server) GetSparseMetadata(w http.ResponseWriter, r *Request)
- func (s *Server) ListenAndServe() error
- func (s *Server) LsBranchReference(w http.ResponseWriter, r *Request, branchName string)
- func (s *Server) LsReference(w http.ResponseWriter, r *Request)
- func (s *Server) LsTagReference(w http.ResponseWriter, r *Request, tagName string)
- func (s *Server) MakeAuthenticateHeader(r *http.Request) string
- func (s *Server) ManagementRouter(r *mux.Router)
- func (s *Server) NewKey(w http.ResponseWriter, r *http.Request)
- func (s *Server) NewRepo(w http.ResponseWriter, r *http.Request)
- func (s *Server) NewUser(w http.ResponseWriter, r *http.Request)
- func (s *Server) OnFunc(fn HandlerFunc, operation protocol.Operation) http.HandlerFunc
- func (s *Server) ParseJWT(w http.ResponseWriter, r *http.Request, bearerToken string) (*database.User, *BearerMD, error)
- func (s *Server) ProtocolZ1Router(r *mux.Router)
- func (s *Server) Push(w http.ResponseWriter, r *Request)
- func (s *Server) PutObject(w http.ResponseWriter, r *Request)
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) ShareAuthorization(w http.ResponseWriter, r *http.Request)
- func (s *Server) ShareObjects(w http.ResponseWriter, r *Request)
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) TagPush(w http.ResponseWriter, r *Request, tagName string)
- type ServerConfig
Constants ¶
View Source
const ( DefaultReadTimeout = 2 * time.Hour DefaultWriteTimeout = 2 * time.Hour DefaultIdleTimeout = 5 * time.Minute )
View Source
const ( DeepenFrom = "deepen-from" // shallow base Deepen = "deepen" // deepen <depth> Have = "have" // local have )
View Source
const ( ErrorMessageKey = "X-Zeta-Error-Message" JSON_MIME = "application/json" )
View Source
const ( // IfNoneMatch = "If-None-Match" ETag = "ETag" // Zeta HTTP Header AUTHORIZATION = "Authorization" ZETA_PROTOCOL = "Zeta-Protocol" ZETA_AUTHORIZATION = "X-Zeta-Authorization" ZETA_COMMAND_OLDREV = "X-Zeta-Command-OldRev" ZETA_COMMAND_NEWREV = "X-Zeta-Command-NewRev" ZETA_TERMINAL = "X-Zeta-Terminal" ZETA_OBJECTS_STATS = "X-Zeta-Objects-Stats" ZETA_COMPRESSED_SIZE = "X-Zeta-Compressed-Size" // ZETA Protocol Content Type ZETA_MIME_BLOB = "application/x-zeta-blob" ZETA_MIME_BLOBS = "application/x-zeta-blobs" ZETA_MIME_MULTI_OBJECTS = "application/x-zeta-multi-objects" ZETA_MIME_MD = "application/x-zeta-metadata" ZETA_MIME_COMPRESS_MD = "application/x-zeta-compress-metadata" ZETA_MIME_REPORT_RESULT = "application/x-zeta-report-result" ZETA_MIME_VND_JSON = "application/vnd.zeta+json" ZETA_MIME_FRAGMENTS_MD = "application/vnd.zeta-fragments+json" // fragments json format )
View Source
const ( GeneralBranch = 0 ProtectedBranch = 10 ArchivedBranch = 20 ConfidentialBranch = 30 )
View Source
const (
BearerPrefix = "Bearer "
)
Variables ¶
View Source
var ( ErrStop = errors.New("stop") ErrAccessDenied = errors.New("access denied") )
Functions ¶
func EqualFold ¶
EqualFold is strings.EqualFold, ASCII only. It reports whether s and t are equal, ASCII-case-insensitively.
func GenerateJWT ¶
func JsonEncode ¶
func JsonEncode(w http.ResponseWriter, a any)
func ZetaEncodeVND ¶
func ZetaEncodeVND(w http.ResponseWriter, a any)
Types ¶
type BearerMD ¶
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *Request)
type NewRepo ¶
type NewRepo struct { Name string `json:"name,omitempty"` Path string `json:"path"` Description string `json:"description"` VisibleLevel int `json:"visible_level,omitempty"` DefaultBranch string `json:"default_branch,omitempty"` // current branch UserName string `json:"username,omitempty"` UID int64 `json:"uid,omitempty"` NamespacePath string `json:"namespace_path,omitempty"` NamespaceID int64 `json:"namespace_id,omitempty"` Empty bool `json:"empty,omitempty"` }
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
ResponseWriter shadow ResponseWriter
func NewResponseWriter ¶
func NewResponseWriter(w http.ResponseWriter, r *http.Request) *ResponseWriter
NewResponseWriter bind ResponseWriter
func (*ResponseWriter) F1RemoteAddr ¶
func (w *ResponseWriter) F1RemoteAddr() string
func (*ResponseWriter) StatusCode ¶
func (w *ResponseWriter) StatusCode() int
StatusCode return statusCode
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(statusCode int)
WriteHeader write header statucode
type Server ¶
type Server struct { *ServerConfig // contains filtered or unexported fields }
func NewServer ¶
func NewServer(sc *ServerConfig) (*Server, error)
func (*Server) BatchCheck ¶
func (s *Server) BatchCheck(w http.ResponseWriter, r *Request)
POST /{namespace}/{repo}/reference/{refname:.*}/objects/batch
func (*Server) BatchMetadata ¶
func (s *Server) BatchMetadata(w http.ResponseWriter, r *Request)
func (*Server) BatchObjects ¶
func (s *Server) BatchObjects(w http.ResponseWriter, r *Request)
POST /{namespace}/{repo}/objects/batch
func (*Server) BranchPush ¶
func (s *Server) BranchPush(w http.ResponseWriter, r *Request, branchName string)
func (*Server) FetchMetadata ¶
func (s *Server) FetchMetadata(w http.ResponseWriter, r *Request)
func (*Server) GetObject ¶
func (s *Server) GetObject(w http.ResponseWriter, r *Request)
GET /{namespace}/{repo}/objects/{oid}
func (*Server) GetSparseMetadata ¶
func (s *Server) GetSparseMetadata(w http.ResponseWriter, r *Request)
GetSparseMetadata: get commit metadata sparse-tree
func (*Server) ListenAndServe ¶
func (*Server) LsBranchReference ¶
func (s *Server) LsBranchReference(w http.ResponseWriter, r *Request, branchName string)
func (*Server) LsReference ¶
func (s *Server) LsReference(w http.ResponseWriter, r *Request)
GET /{namespace}/{repo}/reference/{refname:.*}
func (*Server) LsTagReference ¶
func (s *Server) LsTagReference(w http.ResponseWriter, r *Request, tagName string)
func (*Server) MakeAuthenticateHeader ¶
func (*Server) ManagementRouter ¶
func (*Server) OnFunc ¶
func (s *Server) OnFunc(fn HandlerFunc, operation protocol.Operation) http.HandlerFunc
func (*Server) ProtocolZ1Router ¶
func (*Server) Push ¶
func (s *Server) Push(w http.ResponseWriter, r *Request)
POST /{namespace}/{repo}/reference/{refname:.*}
func (*Server) PutObject ¶
func (s *Server) PutObject(w http.ResponseWriter, r *Request)
PUT /{namespace}/{repo}/reference/{refname:.*}/objects/{oid}
func (*Server) ShareAuthorization ¶
func (s *Server) ShareAuthorization(w http.ResponseWriter, r *http.Request)
ShareAuthorization: POST /{namespace}/{repo}/authorization
func (*Server) ShareObjects ¶
func (s *Server) ShareObjects(w http.ResponseWriter, r *Request)
POST /{namespace}/{repo}/objects/share
type ServerConfig ¶
type ServerConfig struct { Listen string `toml:"listen"` Repositories string `toml:"repositories"` IdleTimeout serve.Duration `toml:"idle_timeout,omitempty"` ReadTimeout serve.Duration `toml:"read_timeout,omitempty"` WriteTimeout serve.Duration `toml:"write_timeout,omitempty"` BannerVersion string `toml:"banner_version,omitempty"` DecryptedKey string `toml:"decrypted_key,omitempty"` Cache *serve.Cache `toml:"cache,omitempty"` DB *serve.Database `toml:"database,omitempty"` ZetaOSS *serve.OSS `toml:"oss,omitempty"` }
func NewServerConfig ¶
func NewServerConfig(file string, expandEnv bool) (*ServerConfig, error)
Click to show internal directories.
Click to hide internal directories.