Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

$mol_model: headers, base_api #492

wants to merge 2 commits into from

Conversation

zerkalica
Copy link
Collaborator

No description provided.


return {
... headers,
'Authorization': `Bearer ${token}`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не думаю, что хорошая идея хардкодить конкретный тип авторизации в общем модуле.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, хотелось бы иметь возможность задать стратегию авторизации такую какую мне надо,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проще всего это сделать через наследование с переопределением метода, возвращающего заголовки.

Copy link
Contributor

@osv osv May 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может оставить заглушкой для переопределения метода headers? В противном случае если авторизация по JWT надо переопределять полностю json() метод, а это много копипасты

Copy link
Member

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 + '/'
Copy link
Member

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 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null используется, чтобы энфорсить повторную загрузку данных.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants