Documentation ¶
Index ¶
- Constants
- func CorsOption(corsOptions *model.CorsOptions) func(*Router) error
- func HostOption(host string) func(*Router) error
- func NewRouter(logger *log.Logger, sServ model.SessionService, sStor model.SessionStorage, ...) (model.Router, error)
- func PathPrefixOptions(prefix string) func(r *Router) error
- func RedirectURLOption(redirectURL string) func(*Router) error
- func ServerConfigPathOption(configPath string) func(*Router) error
- func ServerSettingsOption(settings *model.ServerSettings) func(*Router) error
- type Error
- type Router
- func (ar *Router) CreateApp() http.HandlerFunc
- func (ar *Router) CreateUser() http.HandlerFunc
- func (ar *Router) DeleteApp() http.HandlerFunc
- func (ar *Router) DeleteUser() http.HandlerFunc
- func (ar *Router) Error(w http.ResponseWriter, err error, code int, userInfo string)
- func (ar *Router) FetchAccountSettings() http.HandlerFunc
- func (ar *Router) FetchApps() http.HandlerFunc
- func (ar *Router) FetchConfigurationStorageSettings() http.HandlerFunc
- func (ar *Router) FetchExternalServicesSettings() http.HandlerFunc
- func (ar *Router) FetchGeneralSettings() http.HandlerFunc
- func (ar *Router) FetchLoginSettings() http.HandlerFunc
- func (ar *Router) FetchServerSettings() http.HandlerFunc
- func (ar *Router) FetchSessionStorageSettings() http.HandlerFunc
- func (ar *Router) FetchStaticFilesStorageSettings() http.HandlerFunc
- func (ar *Router) FetchStorageSettings() http.HandlerFunc
- func (ar *Router) FetchUsers() http.HandlerFunc
- func (ar *Router) GetApp() http.HandlerFunc
- func (ar *Router) GetStringifiedFile() http.HandlerFunc
- func (ar *Router) GetUser() http.HandlerFunc
- func (ar *Router) IsLoggedIn() http.HandlerFunc
- func (ar *Router) Login() http.HandlerFunc
- func (ar *Router) Logout() http.HandlerFunc
- func (ar *Router) RestartServer() http.HandlerFunc
- func (ar *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (ar *Router) ServeJSON(w http.ResponseWriter, code int, v interface{})
- func (ar *Router) Session() negroni.HandlerFunc
- func (ar *Router) TestDatabaseConnection() http.HandlerFunc
- func (ar *Router) UpdateAccountSettings() http.HandlerFunc
- func (ar *Router) UpdateApp() http.HandlerFunc
- func (ar *Router) UpdateConfigurationStorageSettings() http.HandlerFunc
- func (ar *Router) UpdateExternalServicesSettings() http.HandlerFunc
- func (ar *Router) UpdateGeneralSettings() http.HandlerFunc
- func (ar *Router) UpdateLoginSettings() http.HandlerFunc
- func (ar *Router) UpdateSessionStorageSettings() http.HandlerFunc
- func (ar *Router) UpdateStaticFilesStorageSettings() http.HandlerFunc
- func (ar *Router) UpdateStorageSettings() http.HandlerFunc
- func (ar *Router) UpdateUser() http.HandlerFunc
- func (ar *Router) UploadADDAFile() http.HandlerFunc
- func (ar *Router) UploadJWTKeys() http.HandlerFunc
- func (ar *Router) UploadStringifiedFile() http.HandlerFunc
Constants ¶
const ( // ErrorWrongInput is for corrupted request data. ErrorWrongInput = Error("Wrong input data") // ErrorRequestInvalidCookie is for invalid cookie. ErrorRequestInvalidCookie = Error("Invalid cookie") // ErrorInternalError is for internal errors. ErrorInternalError = Error("Internal error") // ErrorIncorrectLogin is for incorrect login and password. ErrorIncorrectLogin = Error("Incorrect login information") // ErrorNotAuthorized is for non-authorized access intents. ErrorNotAuthorized = Error("Not authorized") )
Variables ¶
This section is empty.
Functions ¶
func CorsOption ¶
func CorsOption(corsOptions *model.CorsOptions) func(*Router) error
CorsOption sets cors option.
func NewRouter ¶
func NewRouter(logger *log.Logger, sServ model.SessionService, sStor model.SessionStorage, as model.AppStorage, us model.UserStorage, cs model.ConfigurationStorage, sfs model.StaticFilesStorage, options ...func(*Router) error) (model.Router, error)
NewRouter creates and initializes new admin router.
func PathPrefixOptions ¶
PathPrefixOptions sets path prefix options.
func RedirectURLOption ¶
RedirectURLOption sets redirect url value.
func ServerConfigPathOption ¶
ServerConfigPathOption sets path to configuration file with admin server settings.
func ServerSettingsOption ¶
func ServerSettingsOption(settings *model.ServerSettings) func(*Router) error
ServerSettingsOption sets path to configuration file with server settings.
Types ¶
type Router ¶
type Router struct { ServerConfigPath string ServerSettings *model.ServerSettings RedirectURL string PathPrefix string Host string // contains filtered or unexported fields }
Router is a router that handles admin requests.
func (*Router) CreateApp ¶
func (ar *Router) CreateApp() http.HandlerFunc
CreateApp adds new app to the database.
func (*Router) CreateUser ¶
func (ar *Router) CreateUser() http.HandlerFunc
CreateUser registers new user.
func (*Router) DeleteApp ¶
func (ar *Router) DeleteApp() http.HandlerFunc
DeleteApp deletes app from the database by id.
func (*Router) DeleteUser ¶
func (ar *Router) DeleteUser() http.HandlerFunc
DeleteUser deletes user from the database.
func (*Router) FetchAccountSettings ¶
func (ar *Router) FetchAccountSettings() http.HandlerFunc
FetchAccountSettings returns admin account settings.
func (*Router) FetchApps ¶
func (ar *Router) FetchApps() http.HandlerFunc
FetchApps fetches apps from the database.
func (*Router) FetchConfigurationStorageSettings ¶
func (ar *Router) FetchConfigurationStorageSettings() http.HandlerFunc
FetchConfigurationStorageSettings fetches configuration storage settings.
func (*Router) FetchExternalServicesSettings ¶
func (ar *Router) FetchExternalServicesSettings() http.HandlerFunc
FetchExternalServicesSettings fetches settings for external services.
func (*Router) FetchGeneralSettings ¶
func (ar *Router) FetchGeneralSettings() http.HandlerFunc
FetchGeneralSettings fetches server's general settings.
func (*Router) FetchLoginSettings ¶
func (ar *Router) FetchLoginSettings() http.HandlerFunc
FetchLoginSettings fetches app's login settings.
func (*Router) FetchServerSettings ¶
func (ar *Router) FetchServerSettings() http.HandlerFunc
FetchServerSettings returns server settings.
func (*Router) FetchSessionStorageSettings ¶
func (ar *Router) FetchSessionStorageSettings() http.HandlerFunc
FetchSessionStorageSettings fetches session storage settings.
func (*Router) FetchStaticFilesStorageSettings ¶
func (ar *Router) FetchStaticFilesStorageSettings() http.HandlerFunc
FetchStaticFilesStorageSettings fetches static files settings.
func (*Router) FetchStorageSettings ¶
func (ar *Router) FetchStorageSettings() http.HandlerFunc
FetchStorageSettings fetches server's general settings.
func (*Router) FetchUsers ¶
func (ar *Router) FetchUsers() http.HandlerFunc
FetchUsers fetches users from the database.
func (*Router) GetApp ¶
func (ar *Router) GetApp() http.HandlerFunc
GetApp fetches app by ID from the database.
func (*Router) GetStringifiedFile ¶
func (ar *Router) GetStringifiedFile() http.HandlerFunc
GetStringifiedFile fetches static file from the static files storage, and returns its string representation.
func (*Router) GetUser ¶
func (ar *Router) GetUser() http.HandlerFunc
GetUser fetches user by ID from the database.
func (*Router) IsLoggedIn ¶
func (ar *Router) IsLoggedIn() http.HandlerFunc
IsLoggedIn checks if admin is logged in.
func (*Router) Login ¶
func (ar *Router) Login() http.HandlerFunc
Login logins admin with admin name and password.
func (*Router) RestartServer ¶
func (ar *Router) RestartServer() http.HandlerFunc
RestartServer restarts server with new settings.
func (*Router) ServeHTTP ¶
func (ar *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements identifo.Router interface.
func (*Router) ServeJSON ¶
func (ar *Router) ServeJSON(w http.ResponseWriter, code int, v interface{})
ServeJSON sends status code, headers and data back to the user.
func (*Router) Session ¶
func (ar *Router) Session() negroni.HandlerFunc
Session is a middleware to check if admin is logged in with valid cookie. If all checks succeeded, prolongs existing session. If not, forces to login.
func (*Router) TestDatabaseConnection ¶
func (ar *Router) TestDatabaseConnection() http.HandlerFunc
TestDatabaseConnection tests database connection.
func (*Router) UpdateAccountSettings ¶
func (ar *Router) UpdateAccountSettings() http.HandlerFunc
UpdateAccountSettings updates admin account settings.
func (*Router) UpdateApp ¶
func (ar *Router) UpdateApp() http.HandlerFunc
UpdateApp updates app in the database.
func (*Router) UpdateConfigurationStorageSettings ¶
func (ar *Router) UpdateConfigurationStorageSettings() http.HandlerFunc
UpdateConfigurationStorageSettings changes storage connection settings.
func (*Router) UpdateExternalServicesSettings ¶
func (ar *Router) UpdateExternalServicesSettings() http.HandlerFunc
UpdateExternalServicesSettings changes settings for external services.
func (*Router) UpdateGeneralSettings ¶
func (ar *Router) UpdateGeneralSettings() http.HandlerFunc
UpdateGeneralSettings changes server's general settings.
func (*Router) UpdateLoginSettings ¶
func (ar *Router) UpdateLoginSettings() http.HandlerFunc
UpdateLoginSettings changes app's login settings.
func (*Router) UpdateSessionStorageSettings ¶
func (ar *Router) UpdateSessionStorageSettings() http.HandlerFunc
UpdateSessionStorageSettings changes admin session storage connection settings.
func (*Router) UpdateStaticFilesStorageSettings ¶
func (ar *Router) UpdateStaticFilesStorageSettings() http.HandlerFunc
UpdateStaticFilesStorageSettings changes static files settings.
func (*Router) UpdateStorageSettings ¶
func (ar *Router) UpdateStorageSettings() http.HandlerFunc
UpdateStorageSettings changes storage connection settings.
func (*Router) UpdateUser ¶
func (ar *Router) UpdateUser() http.HandlerFunc
UpdateUser updates user in the database.
func (*Router) UploadADDAFile ¶
func (ar *Router) UploadADDAFile() http.HandlerFunc
UploadADDAFile is for uploading Apple Developer Domain Association File.
func (*Router) UploadJWTKeys ¶
func (ar *Router) UploadJWTKeys() http.HandlerFunc
UploadJWTKeys is for uploading public and private keys used for signing JWTs.
func (*Router) UploadStringifiedFile ¶
func (ar *Router) UploadStringifiedFile() http.HandlerFunc
UploadStringifiedFile uploads stringified static file to the storage.