Files
kopia/internal/server/request_context.go
Jarek Kowalski c1757a0c67 feat(general): misc notifications improvements (#4319)
* feat(general): various notifications improvements

* added API to test notification profiles
* added --http-header to webhook notification configuration
* refactored configuration to always apply defaults before persisting options in the repository
* added 'notification profile show --profile-name=X' command

* more tests

* more test coverage

* report notification code coverage
2024-12-29 09:50:20 -08:00

57 lines
1.7 KiB
Go

package server
import (
"context"
"net/http"
"time"
"github.com/gorilla/mux"
"github.com/kopia/kopia/internal/auth"
"github.com/kopia/kopia/internal/mount"
"github.com/kopia/kopia/internal/uitask"
"github.com/kopia/kopia/repo"
"github.com/kopia/kopia/repo/object"
"github.com/kopia/kopia/snapshot"
)
//nolint:interfacebloat
type serverInterface interface {
deleteSourceManager(ctx context.Context, src snapshot.SourceInfo) bool
generateShortTermAuthCookie(username string, now time.Time) (string, error)
isAuthCookieValid(username, cookieValue string) bool
getAuthorizer() auth.Authorizer
getAuthenticator() auth.Authenticator
getOptions() *Options
snapshotAllSourceManagers() map[snapshot.SourceInfo]*sourceManager
taskManager() *uitask.Manager
Refresh()
getMountController(ctx context.Context, rep repo.Repository, oid object.ID, createIfNotFound bool) (mount.Controller, error)
deleteMount(oid object.ID)
listMounts() map[object.ID]mount.Controller
disconnect(ctx context.Context) error
requestShutdown(ctx context.Context)
getOrCreateSourceManager(ctx context.Context, src snapshot.SourceInfo) *sourceManager
getInitRepositoryTaskID() string
getConnectOptions(cliOpts repo.ClientOptions) *repo.ConnectOptions
SetRepository(ctx context.Context, rep repo.Repository) error
InitRepositoryAsync(ctx context.Context, mode string, initializer InitRepositoryFunc, wait bool) (string, error)
rootContext() context.Context
}
type requestContext struct {
w http.ResponseWriter
req *http.Request
body []byte
rep repo.Repository
srv serverInterface
}
func (r *requestContext) muxVar(s string) string {
return mux.Vars(r.req)[s]
}
func (r *requestContext) queryParam(s string) string {
return r.req.URL.Query().Get(s)
}