Documentation ¶
Index ¶
- Variables
- func Dump(schema Response, r *http.Request, w http.ResponseWriter) error
- func ErrContentType(contentType string) error
- func ErrFieldsRequired(params ...string) error
- func ErrInvalidData(name string, value interface{}) error
- func ErrLogin(format string, v ...interface{}) error
- func ErrMalformedData(e error, format string, v ...interface{}) error
- func ErrMethodNotAllowed(method string) error
- func ErrNotFound(objType, key, id interface{}) error
- func ErrNotSaved(obj interface{}) error
- func ErrNullData() error
- func ErrNullObject(obj string) error
- func ErrOperationNotAuthorized(operation, obj, id string) error
- func ErrOperationNotSupported(operation, obj string) error
- func ErrParamsRequired(params ...string) error
- func ErrReadOnly(objType, field string) error
- func ErrTokenMissing() error
- func ErrTokenType() error
- func Load(schema Request, r *http.Request) error
- type AppRequestSchema
- type AppResponseSchema
- type AuthProvider
- type AuthRequestSchema
- type AuthResponseSchema
- type ContentType
- type CounterRequestSchema
- type CounterResponseSchema
- type Credentials
- type CustomerRequestSchema
- type CustomerResponseSchema
- type Decoder
- type Encoder
- type LoginRequestSchema
- type PaginationRequestSchema
- type PaginationResponseSchema
- type Param
- type PermissionEntry
- type Plan
- type Request
- type Response
- type RoomRecording
- type RoomRequestSchema
- type RoomResponseSchema
- type Schema
- func App(model *db.App) Schema
- func AppList(list *db.AppList) Schema
- func Auth(model *db.Auth) Schema
- func AuthList(list *db.AuthList) Schema
- func Counter(model *db.Counter) Schema
- func Customer(model *db.Customer) Schema
- func CustomerList(list *db.CustomerList) Schema
- func Error(err error) Schema
- func Login(req *LoginRequestSchema) Schema
- func Message(format string, v ...interface{}) Schema
- func Model(model db.Model) Schema
- func ModelList(list db.ModelList) Schema
- func Room(model *db.Room) Schema
- func RoomList(list *db.RoomList) Schema
- func Session(model *db.Session) Schema
- func SessionList(list *db.SessionList) Schema
- func Token(req *TokenRequestSchema) Schema
- func User(model *db.User) Schema
- func UserList(list *db.UserList) Schema
- type SessionRecording
- type SessionRequestSchema
- type SessionResponseSchema
- type TokenRequestSchema
- type TokenResponseSchema
- type UploadInfo
- type UserRequestSchema
- type UserResponseSchema
- type Webhook
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultPaginationLimit ... DefaultPaginationLimit = 10 // MaxPaginationLimit ... MaxPaginationLimit = 100 )
var ( // ContentTypeNull ... ContentTypeNull = &ContentType{value: "null", encoder: func(writer http.ResponseWriter) Encoder { return nil }, decoder: func(request *http.Request) Decoder { return nil }, errParser: func(e error) error { return e }} // ContentTypeJSON ... ContentTypeJSON = &ContentType{value: "application/json", encoder: func(writer http.ResponseWriter) Encoder { return json.NewEncoder(writer) }, decoder: func(request *http.Request) Decoder { dec := json.NewDecoder(request.Body) dec.DisallowUnknownFields() return dec }, errParser: jsonErrorParser, } // ContentTypeYAML ... ContentTypeYAML = &ContentType{value: "application/yaml", encoder: func(writer http.ResponseWriter) Encoder { return yaml.NewEncoder(writer) }, decoder: func(request *http.Request) Decoder { return yaml.NewDecoder(request.Body) }, errParser: yamlErrorParser, } // ContentTypeDefault ... ContentTypeDefault = ContentTypeJSON )
var ( // TokenExpiration ... TokenExpiration = time.Hour * 24 * 7 // TokenAlgorithm ... TokenAlgorithm = "HS256" )
var (
// DefaultAuthFailureMessage default message for auth error
DefaultAuthFailureMessage = "Incorrect email or password"
)
var ( // ReservedRoles ... ReservedRoles = []string{"default", "admin"} )
Functions ¶
func ErrMalformedData ¶
ErrMalformedData ...
func ErrOperationNotAuthorized ¶
ErrOperationNotAuthorized ...
func ErrOperationNotSupported ¶
ErrOperationNotSupported ...
Types ¶
type AppRequestSchema ¶
type AppRequestSchema struct { Name *string `json:"name,omitempty" yaml:"name,omitempty" createValidate:"required" validate:"omitempty,min=1,max=512,alpha"` Description *string `json:"description,omitempty" yaml:"description,omitempty" validate:"omitempty,min=1,max=1024"` Customer *string `json:"customer,omitempty" yaml:"customer,omitempty" createValidate:"omitempty,mongoobjectid"` Active *bool `json:"active,omitempty" yaml:"active,omitempty"` }
AppRequestSchema app request
type AppResponseSchema ¶
type AppResponseSchema struct { ID string `json:"id" yaml:"id"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Customer string `json:"customer,omitempty" yaml:"customer,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"` }
AppResponseSchema ...
type AuthProvider ¶
type AuthProvider interface { AccessKey() string GetUserID() string GetCustomerID() string GetSecret() string GetAppID() string IsAdmin() bool }
AuthProvider ...
type AuthRequestSchema ¶
type AuthRequestSchema struct { User *string `json:"user,omitempty" yaml:"user,omitempty" createValidate:"excluded_with=App,omitempty,mongoobjectid"` App *string `json:"app,omitempty" yaml:"app,omitempty" createValidate:"excluded_with=User,omitempty,mongoobjectid"` Active *bool `json:"active,omitempty" yaml:"active,omitempty"` Secret *string `json:"secret,omitempty" yaml:"secret,omitempty" validate:"omitempty,alnum,min=8,max=2048"` Revoke []string `json:"revoked,omitempty" yaml:"revoked,omitempty"` }
AuthRequestSchema ...
type AuthResponseSchema ¶
type AuthResponseSchema struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` AccessKey string `json:"access_key,omitempty" yaml:"access_key,omitempty"` UserID string `json:"user,omitempty" yaml:"user,omitempty"` CustomerID string `json:"customer,episodesCollectionomitempty" yaml:"customer,omitempty"` AppID string `json:"app,omitempty" yaml:"app,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"` }
AuthResponseSchema ...
type ContentType ¶
type ContentType struct {
// contains filtered or unexported fields
}
ContentType ...
func (*ContentType) Decoder ¶
func (c *ContentType) Decoder(request *http.Request) Decoder
Decoder get decoder
func (*ContentType) Encoder ¶
func (c *ContentType) Encoder(writer http.ResponseWriter) Encoder
Encoder get encoder
func (*ContentType) Write ¶
func (c *ContentType) Write(writer http.ResponseWriter, opts ...string)
Write write content type
type CounterRequestSchema ¶
type CounterRequestSchema struct { Subscription *int64 `json:"subscription,omitempty" yaml:"subscription,omitempty"` Bandwidth *int64 `json:"bandwidth,omitempty" yaml:"bandwidth,omitempty"` }
CounterRequestSchema ..
type CounterResponseSchema ¶
type CounterResponseSchema struct { ID string `json:"id" yaml:"id"` Subscription int64 `json:"subscription" yaml:"subscription"` Bandwidth int64 `json:"bandwidth" yaml:"bandwidth"` }
CounterResponseSchema ...
type Credentials ¶
type Credentials struct { Key string `json:"key,omitempty" yaml:"key,omitempty"` Secret string `json:"secret,omitempty" yaml:"secret,omitempty"` }
Credentials for upload
type CustomerRequestSchema ¶
type CustomerRequestSchema struct { User *string `json:"user,omitempty" yaml:"user,omitempty" createValidate:"required,mongoobjectid" validate:"omitempty,mongoobjectid"` Active *bool `json:"active,omitempty" yaml:"active,omitempty" ` Plan *Plan `json:"plan,omitempty" yaml:"plan,omitempty"` Webhook *Webhook `json:"webhook,omitempty" yaml:"webhook,omitempty"` }
CustomerRequestSchema request customer
type CustomerResponseSchema ¶
type CustomerResponseSchema struct { ID string `json:"id" json:"id"` User string `json:"user,omitempty" yaml:"user,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Plan *Plan `json:"plan,omitempty" yaml:"plan,omitempty"` }
CustomerResponseSchema customer response
type LoginRequestSchema ¶
type LoginRequestSchema struct { Email string `json:"email,omitempty" yaml:"email,omitempty" validate:"required,email"` Password string `json:"password,omitempty" yaml:"password,omitempty" validate:"required,min=1,max=128"` Expiry int `json:"expiry,omitempty" yaml:"expiry,omitempty" validate:"omitempty,min=60,max=8640000"` }
LoginRequestSchema ...
type PaginationRequestSchema ¶
type PaginationRequestSchema struct { Limit int `validate:"omitempty,min=1,max=100"` Start string `validate:"omitempty,min=1"` }
PaginationRequestSchema ...
func (*PaginationRequestSchema) Load ¶
func (req *PaginationRequestSchema) Load(r *http.Request) error
Load ...
func (*PaginationRequestSchema) String ¶
func (req *PaginationRequestSchema) String() string
type PaginationResponseSchema ¶
type PaginationResponseSchema struct { Limit int `json:"limit" yaml:"limit"` Data interface{} `json:"data" yaml:"data"` Last string `json:"last" yaml:"last"` }
PaginationResponseSchema ...
func (*PaginationResponseSchema) SetLimit ¶
func (page *PaginationResponseSchema) SetLimit(limit int)
SetLimit ...
func (*PaginationResponseSchema) String ¶
func (page *PaginationResponseSchema) String() string
type PermissionEntry ¶
type PermissionEntry struct { Publish []string `yaml:"publish,omitempty" json:"publish,omitempty"` Subscribe []string `yaml:"subscribe,omitempty" json:"subscribe,omitempty"` Commands []string `yaml:"commands,omitempty" json:"commands,omitempty"` }
PermissionEntry permission for room
func NewPermission ¶
func NewPermission(entry *db.RoomPermissionEntry) *PermissionEntry
NewPermission create new permission entry
type Plan ¶
type Plan struct { Subscription int64 `json:"subscription,omitempty" yaml:"subscription,omitempty"` Bandwidth int64 `json:"bandwidth,omitempty" yaml:"bandwidth,omitempty"` RoomSize int64 `json:"room_size,omitempty" yaml:"room_size,omitempty"` RoomCount int64 `json:"room_count,omitempty" yaml:"room_count,omitempty"` PeerCount int64 `json:"peer_count,omitempty" yaml:"peer_count,omitempty"` }
Plan customer Plan
type Request ¶
type Request interface { Name() string Partial() bool RequestBuffer() interface{} WriteRequest(data interface{}) error }
Request ...
type Response ¶
type Response interface { Name() string ResponseBuffer() interface{} Code() int ReadResponse(data interface{}) error }
Response ...
type RoomRecording ¶
type RoomRecording struct { Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"` Size int64 `yaml:"size,omitempty" json:"size,omitempty"` Duration time.Duration `yaml:"duration,omitempty" json:"duration,omitempty"` Upload *UploadInfo `yaml:"upload,omitempty" json:"upload,omitempty"` }
RoomRecording recording info
type RoomRequestSchema ¶
type RoomRequestSchema struct { Name *string `json:"name,omitempty" yaml:"name,omitempty" createValidate:"required" validate:"omitempty,min=1,max=512,alphanum"` Active *bool `json:"active,omitempty" yaml:"active,omitempty"` Size *int `json:"size,omitempty" yaml:"size,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty" validate:"omitempty,min=1,max=1024"` User string `json:"user,omitempty" yaml:"user,omitempty" validate:"required,mongoobjectid"` Roles []string `json:"roles,omitempty" yaml:"roles,omitempty" validate:"omitempty,min=1,max=100,dive,min=1,max=128"` Waiting *bool `json:"waiting,omitempty" yaml:"waiting,omitempty"` Locked *bool `json:"locked,omitempty" yaml:"locked,omitempty"` Recording *RoomRecording `json:"recording,omitempty" yaml:"recording,omitempty"` Permissions map[string]*PermissionEntry `json:"permission,omitempty" yaml:"permission,omitempty"` Template string `json:"template,omitempty" yaml:"template,omitempty"` }
RoomRequestSchema room request
type RoomResponseSchema ¶
type RoomResponseSchema struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Size int `json:"size,omitempty" yaml:"size,omitempty"` Locked bool `json:"locked,omitempty" yaml:"locked,omitempty"` Waiting bool `json:"waiting,omitempty" yaml:"waiting,omitempty"` Roles []string `json:"roles,omitempty" yaml:"roles,omitempty"` Recording *RoomRecording `json:"recording,omitempty" yaml:"recording,omitempty"` Permissions map[string]*PermissionEntry `json:"permissions,omitempty" yaml:"permissions,omitempty"` Template string `json:"template,omitempty" yaml:"template,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` User string `json:"user,omitempty" yaml:"user,omitempty"` Customer string `json:"customer,omitempty" yaml:"customer,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"` }
RoomResponseSchema ...
type Schema ¶
type Schema interface { Name() string Request() Request Response() Response WithAuth(AuthProvider) Schema Paginate(limit int) error }
Schema ...
type SessionRecording ¶
type SessionRecording struct { Location string `json:"location,omitempty" yaml:"location,omitempty"` Size int64 `json:"size,omitempty" yaml:"size,omitempty"` Available bool `json:"available,omitempty" yaml:"available,omitempty"` Duration time.Duration `json:"closed,omitempty" yaml:"closed,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` }
SessionRecording ...
type SessionRequestSchema ¶
type SessionRequestSchema struct { Room *string `json:"room,omitempty" yaml:"customer,omitempty" createValidate:"required,mongoobjectid"` Active *bool `json:"active,omitempty" yaml:"active,omitempty"` Peers []string `json:"peers,omitempty" yaml:"peers,omitempty"` Recordings []*SessionRecording `json:"recordings,omitempty" yaml:"recordings,omitempty"` }
SessionRequestSchema session request
type SessionResponseSchema ¶
type SessionResponseSchema struct { ID string `json:"_id,omitempty" yaml:"_id,omitempty"` Room string `json:"room_id,omitempty" yaml:"room_id,omitempty"` Customer string `json:"customer_id,omitempty" yaml:"customer_id,omitempty"` User string `json:"user_id,omitempty" yaml:"user_id,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Peers []string `json:"peers,omitempty" yaml:"peers,omitempty"` Recordings []*SessionRecording `json:"recordings,omitempty" yaml:"recordings,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"` }
SessionResponseSchema ...
type TokenRequestSchema ¶
type TokenRequestSchema struct { Duration int Starts int RoomID string PeerID string AccessKey string `validate:"required"` Role string }
TokenRequestSchema ...
func (*TokenRequestSchema) Load ¶
func (schema *TokenRequestSchema) Load(auth AuthProvider) error
Load ...
type TokenResponseSchema ¶
type TokenResponseSchema struct { Token string `json:"token,omitempty" yaml:"token,omitempty"` Expiry time.Time `json:"expiry,omitempty" yaml:"expiry,omitempty"` }
TokenResponseSchema ...
func (*TokenResponseSchema) Load ¶
func (schema *TokenResponseSchema) Load(authProvider AuthProvider, req *TokenRequestSchema) error
Load ...
type UploadInfo ¶
type UploadInfo struct { Type string `json:"type,omitempty" yaml:"type,omitempty" validate:"required,eq=s3"` Location string `json:"location,omitempty" yaml:"location,omitempty" validate:"required,min=1,max=128"` Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty" validate:"omitempty,min=1,max=128"` Credentials *Credentials `json:"credentials,omitempty" yaml:"credentials,omitempty"` Options map[string]string `json:"options,omitempty" yaml:"options,omitempty"` }
UploadInfo is Recording info of the room
type UserRequestSchema ¶
type UserRequestSchema struct { Name *string `json:"name,omitempty" yaml:"name,omitempty" validate:"omitempty,min=1,max=512,alpha"` Email *string `json:"email,omitempty" yaml:"email,omitempty" createValidate:"required,email"` Phone *string `json:"phone,omitempty" yaml:"phone,omitempty" validate:"omitempty,len=10,number"` Password *string `json:"password,omitempty" yaml:"password,omitempty" createValidate:"required" validate:"min=6,max=128"` Active *bool `json:"active,omitempty" yaml:"active,omitempty"` Customer *bool `json:"customer,omitempty" yaml:"customer,omitempty"` Roles []string `json:"roles,omitempty" yaml:"roles,omitempty" validate:"omitempty,min=1,max=100,dive,min=1,max=128"` }
UserRequestSchema user info
type UserResponseSchema ¶
type UserResponseSchema struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Email string `json:"email,omitempty" yaml:"email,omitempty"` Phone string `json:"phone,omitempty" yaml:"phone,omitempty"` Active bool `json:"active,omitempty" yaml:"active,omitempty"` Locked bool `json:"locked,omitempty" yaml:"locked,omitempty"` CreatedAt time.Time `json:"created_at,omitempty" yaml:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty" yaml:"updated_at,omitempty"` }
UserResponseSchema ...