-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfaces.go
49 lines (45 loc) · 1.66 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package request
// Default request user interface.
// This interface is used to check if a user is authenticated.
// This interface is used by the LoginRequiredMiddleware and LogoutRequiredMiddleware.
// If you want to use these middlewares, you should implement this interface.
// And set the GetRequestUserFunc function to return a user.
type User interface {
// Check if the user is authenticated
IsAuthenticated() bool
// Check if the user is an administator
IsAdmin() bool
}
// This interface will be set on the request, but is only useful if any middleware
// is using it. If no middleware has set it, it will remain unused.
type Session interface {
Set(key string, value interface{})
Get(key string) interface{}
Exists(key string) bool
Delete(key string)
Destroy() error
RenewToken() error
}
// Default logger interface, can be used to set a logger on the request.
// This logger can be set in for example, the middleware, and then be used in the views by the request.
type Logger interface {
// Write a critical error message
// This message should be handled differently
// than the other ways of reporting.
Critical(err error)
// Write an error message, loglevel error
Error(args ...any)
Errorf(format string, args ...any)
// Write a warning message, loglevel warning
Warning(args ...any)
Warningf(format string, args ...any)
// Write an info message, loglevel info
Info(args ...any)
Infof(format string, args ...any)
// Write a debug message, loglevel debug
Debug(args ...any)
Debugf(format string, args ...any)
// Write a test message, loglevel test
Test(args ...any)
Testf(format string, args ...any)
}