1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- package rest_websocket
- import (
- "git.ali33.ru/fcg-xvii/go-tools/json"
- "git.ali33.ru/fcg-xvii/rest"
- )
- type RequestIn struct {
- *rest.RequestStream
- owner *SocketServer
- core any
- }
- func (s *RequestIn) Auth() json.Map {
- return s.owner.auth
- }
- func (s *RequestIn) SetAuth(auth json.Map) {
- s.owner.auth = auth
- }
- func (s *RequestIn) GenerateToken(data json.Map, expire int64) (string, error) {
- return s.owner.appConf.tokenGenerator(data, expire)
- }
- func (s *RequestIn) ParseToken(tokenString string) (json.Map, error) {
- return s.owner.appConf.tokenParser(tokenString)
- }
- func (s *RequestIn) ROwner() rest.IOwner {
- return s.owner
- }
- func (s *RequestIn) RCore() any {
- return s.core
- }
- func (s *RequestIn) ClientData(key string) (any, bool) {
- res, check := s.owner.clientData[key]
- return res, check
- }
- func (s *RequestIn) SetClientData(key string, data any) {
- s.owner.clientData[key] = data
- }
- func (s *RequestIn) OutSuccess(data json.Map, files rest.RequestFiles) rest.IRequestOut {
- return &rest.RequestStream{
- ID: s.ID,
- Request: &rest.Request{
- Type: rest.RequestTypeOut,
- Command: s.Command,
- Data: data,
- Files: files,
- },
- }
- }
- func (s *RequestIn) OutError(err rest.IErrorArgs) rest.IRequestOut {
- return &rest.RequestStream{
- ID: s.ID,
- Request: &rest.Request{
- Type: rest.RequestTypeOut,
- Command: s.Command,
- Data: err.Map(),
- },
- }
- }
|