123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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) Fields() rest.FieldList {
- return rest.FieldListFromSlice(s.RData().Slice("Fields", nil))
- }
- 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(),
- },
- }
- }
|