12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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) 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(),
- },
- }
- }
|