mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-16 07:20:59 +00:00
docs: add section for Request Modifiers in Content types document
This commit is contained in:
parent
0af4bad906
commit
29910a2698
1 changed files with 47 additions and 1 deletions
|
@ -70,7 +70,7 @@ A feed object representing a community post with text, and optionally images.
|
|||
|
||||
*Usage:*
|
||||
```javascript
|
||||
new PlatformPost{
|
||||
new PlatformPost({
|
||||
id: new PlatformID(config.name, item?.id, config.id),
|
||||
name: item?.attributes?.title,
|
||||
author: getPlatformAuthorLink(item, context),
|
||||
|
@ -276,4 +276,50 @@ new PlatformPostDetails{
|
|||
});
|
||||
```
|
||||
|
||||
# Request Modifiers
|
||||
Sources support request modifiers that allow to modify HTTP headers before sending requests. This is useful when a source requires specific headers for authentication, content type specification, or other requirements.
|
||||
|
||||
## Using requestModifier property
|
||||
|
||||
```
|
||||
new HLSSource({
|
||||
//Your other properties...
|
||||
requestModifier: {
|
||||
headers: {
|
||||
"Referer": "https://www.example.com/",
|
||||
"Origin": "https://www.example.com"
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Custom source implementation
|
||||
|
||||
```
|
||||
class YourAudioSource extends AudioUrlRangeSource {
|
||||
constructor(obj) {
|
||||
super(obj);
|
||||
}
|
||||
|
||||
getRequestModifier() {
|
||||
return new YourRequestModifier();
|
||||
}
|
||||
}
|
||||
|
||||
class YourRequestModifier extends RequestModifier {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
modifyRequest(url, headers) {
|
||||
//modify headers
|
||||
|
||||
return {
|
||||
url: url,
|
||||
headers: headers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue