Documentation ¶
Index ¶
- Variables
- func Btoi(b bool) int
- func DeleteSession(c echo.Context)
- func FormatRequestPrint(r *http.Request) string
- func GetAccessToken(key interface{}) ([]byte, error)
- func Itob(i int) bool
- func RedisSession() echo.MiddlewareFunc
- func RespConflict(k string, i interface{}) interface{}
- func RespCreated() interface{}
- func RespCustom(m string, k *string, i interface{}) interface{}
- func RespInternelServerError() interface{}
- func RespNoContent(k string, i interface{}) interface{}
- func SessionAuth(next echo.HandlerFunc) echo.HandlerFunc
- func SetSession(c echo.Context, user *UserSession)
- type AccessList
- type Additional
- type ApiError
- type GobSerializer
- type JsonError
- type KeyGenFunc
- type Model
- type ModelCreate
- type RedisStore
- func (s *RedisStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *RedisStore) KeyGen(f KeyGenFunc)
- func (s *RedisStore) KeyPrefix(keyPrefix string)
- func (s *RedisStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *RedisStore) Options(opts sessions.Options)
- func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *RedisStore) Serializer(ss SessionSerializer)
- type ResponseMessage
- type SessionSerializer
- type UserRequest
- type UserSession
Constants ¶
This section is empty.
Variables ¶
var ( ErrorNotFound = errors.New("NotFound") ErrorConflict = errors.New("Conflict") ErrorPassword = errors.New("Password") ErrorUserNotFound = errors.New("user not found") )
var CORSConfig = middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: strings.Split(os.Getenv("ALLOW_ORIGINS"), ","), AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept}, AllowCredentials: true, })
Functions ¶
func DeleteSession ¶
func DeleteSession(c echo.Context)
func FormatRequestPrint ¶
func GetAccessToken ¶
func RedisSession ¶
func RedisSession() echo.MiddlewareFunc
func RespConflict ¶
func RespConflict(k string, i interface{}) interface{}
func RespCreated ¶
func RespCreated() interface{}
func RespCustom ¶
func RespInternelServerError ¶
func RespInternelServerError() interface{}
func RespNoContent ¶
func RespNoContent(k string, i interface{}) interface{}
func SessionAuth ¶
func SessionAuth(next echo.HandlerFunc) echo.HandlerFunc
func SetSession ¶
func SetSession(c echo.Context, user *UserSession)
Types ¶
type AccessList ¶
type Additional ¶
type Additional map[string]interface{}
type ApiError ¶
type ApiError struct { Error error Model string Line int FileName string UserEmail string UserUuid string }
func (*ApiError) PrintErrorNoSession ¶
func (e *ApiError) PrintErrorNoSession(c echo.Context, i interface{})
type GobSerializer ¶
type GobSerializer struct{}
Gob serializer
func (GobSerializer) Deserialize ¶
func (gs GobSerializer) Deserialize(d []byte, s *sessions.Session) error
type JsonError ¶
func JsonErrorResponse ¶
type KeyGenFunc ¶
KeyGenFunc defines a function used by store to generate a key
type Model ¶
type Model struct { Uuid string `json:"uuid" validate:"required"` Name string `json:"name" validate:"required"` Service string `json:"service" validate:"required"` Creator string `json:"owner" validate:"required"` Created int64 `json:"created" validate:"required"` }
Model can be every model
type ModelCreate ¶
type ModelCreate struct { Uuid string `json:"uuid" validate:"required"` Name string `json:"name" validate:"required"` Service string `json:"service" validate:"required"` Creator string `json:"owner" validate:"required"` }
func (*ModelCreate) Model ¶
func (m_create *ModelCreate) Model(created int64) *Model
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore stores gorilla sessions in Redis
func NewRedisStore ¶
func NewRedisStore(client redis.UniversalClient) (*RedisStore, error)
NewRedisStore returns a new RedisStore with default configuration
func (*RedisStore) KeyGen ¶
func (s *RedisStore) KeyGen(f KeyGenFunc)
KeyGen sets the key generator function
func (*RedisStore) KeyPrefix ¶
func (s *RedisStore) KeyPrefix(keyPrefix string)
KeyPrefix sets the key prefix to store session in Redis
func (*RedisStore) New ¶
New returns a session for the given name without adding it to the registry.
func (*RedisStore) Options ¶
func (s *RedisStore) Options(opts sessions.Options)
Options set options to use when a new session is created
func (*RedisStore) Save ¶
func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
If the Options.MaxAge of the session is <= 0 then the session file will be deleted from the store. With this process it enforces the properly session cookie handling so no need to trust in the cookie management in the web browser.
func (*RedisStore) Serializer ¶
func (s *RedisStore) Serializer(ss SessionSerializer)
Serializer sets the session serializer to store session
type ResponseMessage ¶
type SessionSerializer ¶
type SessionSerializer interface { Serialize(s *sessions.Session) ([]byte, error) Deserialize(b []byte, s *sessions.Session) error }
SessionSerializer provides an interface for serialize/deserialize a session
type UserRequest ¶
type UserRequest struct {
Uuid map[string]Additional `json:"uuid" validate:"required"`
}
func (*UserRequest) Filter ¶
func (f *UserRequest) Filter() string
type UserSession ¶
type UserSession struct { Uuid string `json:"uuid"` Email string `json:"email"` Confirmed bool `json:"confirmed"` PrivacyPolicy bool `json:"privacy_policy"` Country string `json:"country"` Access map[string]map[string][]string `json:"access"` Additional Additional `json:"additional"` Updated int64 `json:"updated"` Created int64 `json:"created"` }
func GetUser ¶
func GetUser(c echo.Context) (u *UserSession, contains bool)