rest

package
v0.0.0-...-3462dce Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2021 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInternal      = 0
	ErrValidation    = 1
	ErrAuthorization = 2
)

Variables

This section is empty.

Functions

func GetAuthTokenFromHeader

func GetAuthTokenFromHeader(r *http.Request) (string, error)

func SendAuthorizationErrorJSON

func SendAuthorizationErrorJSON(w http.ResponseWriter, r *http.Request, err error)

func SendErrorJSON

func SendErrorJSON(w http.ResponseWriter, r *http.Request, httpStatusCode int, err error, details string, errCode int)

func SendValidationErrorJSON

func SendValidationErrorJSON(w http.ResponseWriter, r *http.Request, err error)

Types

type AdminProjectStore

type AdminProjectStore interface {
	Create(record repository.Project) (*mongo.InsertOneResult, error)
	Search(form repository.ProjectSearchForm) ([]repository.Project, error)
	Update(record repository.Project) (string, error)
	Delete(projectID string) error
}

type Authenticator

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

func (*Authenticator) HasRole

func (a *Authenticator) HasRole(role string) func(http.Handler) http.Handler

func (*Authenticator) HttpMiddleware

func (a *Authenticator) HttpMiddleware(next http.Handler) http.Handler

type BaseTagStore

type BaseTagStore interface {
	Create(tag repository.Tag) (*mongo.InsertOneResult, error)
	UpdateBaseTag(tag repository.Tag) (string, error)
	DeleteBaseTag(tagID string) error
}

type DayStore

type DayStore interface {
	FindByDateRange(from time.Time, to time.Time, userID string) ([]repository.Day, error)
	FindByDate(date time.Time, userID string) (repository.Day, error)
}

type EventService

type EventService interface {
	Create(record repository.Event, userID string) (string, error)
	Update(event repository.Event, userID string) (string, error)
	Delete(eventID string, userID string) error
	GetUsedNames(userID string, tagID string, from time.Time, to time.Time) ([]string, error)
}

type Form

type Form interface {
	IsValid() []error
}

type FormValidator

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

func CreateValidator

func CreateValidator() *FormValidator

type ManagerTagStore

type ManagerTagStore interface {
	Create(tag repository.Tag) (*mongo.InsertOneResult, error)
	Update(tag repository.Tag) (string, error)
	DeleteByProjectID(tagID string, projectIDs []string) error
	Delete(tagID string) error
}

type ProjectStore

type ProjectStore interface {
	FindAllActiveProjectsByUser(userID string) (repository.Projects, error)
}

type RealmAccess

type RealmAccess struct {
	Roles []string `json:"roles"`
}

type RestServer

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

func CreateRestServer

func CreateRestServer(database *mongo.Database, keycloakUrl string) (*RestServer, error)

func (*RestServer) Run

func (s *RestServer) Run() error

func (*RestServer) Shutdown

func (s *RestServer) Shutdown()

type SettingsStore

type SettingsStore interface {
	FindByUser(userID string) (*repository.Settings, error)
	CreateOrUpdate(settings repository.Settings) error
}

type TagStore

type TagStore interface {
	FindAllBaseAndProjectActiveTags(projectID []string) ([]repository.Tag, error)
	FindAllActive() ([]repository.Tag, error)
}

type UserInfo

type UserInfo struct {
	ID    string
	Roles []string
}

func GetUserInfo

func GetUserInfo(request *http.Request) (UserInfo, error)

Jump to

Keyboard shortcuts

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