-
-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$mol_model: headers, base_api #492
base: master
Are you sure you want to change the base?
Conversation
|
||
return { | ||
... headers, | ||
'Authorization': `Bearer ${token}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не думаю, что хорошая идея хардкодить конкретный тип авторизации в общем модуле.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да, хотелось бы иметь возможность задать стратегию авторизации такую какую мне надо,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проще всего это сделать через наследование с переопределением метода, возвращающего заголовки.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Может оставить заглушкой для переопределения метода headers? В противном случае если авторизация по JWT надо переопределять полностю json() метод, а это много копипасты
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Агась, логично.
uri() { | ||
return '' | ||
} | ||
|
||
@ $mol_mem | ||
api_base( next?: string ) { | ||
return this.$.$mol_state_local.value( '$api_base', next ) ?? $mol_dom_context.location.origin + '/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Разные модели могут работать с разными api.
} | ||
|
||
method_put() { | ||
return 'PUT' | ||
} | ||
|
||
@ $mol_mem | ||
json( next? : null | Partial< Raw > ): Raw { | ||
json( next? : Raw ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null
используется, чтобы энфорсить повторную загрузку данных.
No description provided.