-
Notifications
You must be signed in to change notification settings - Fork 16
/
negotiator_accepts.node.txt
51 lines (35 loc) · 3.02 KB
/
negotiator_accepts.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
NEGOTIATOR_ACCEPTS
ALTERNATIVES ==> # - negotiator|accepts (preferred with Node)
# - deno negotiation (preferred with Deno)
GOAL ==> #HTTP content negotiation
#Used by EXPRESS
/=+===============================+=\
/ : : \
)==: NEGOTIATOR :==(
\ :_______________________________: /
\=+===============================+=/
VERSION ==> #0.6.3
new Negotiator(REQ) #
NTIATOR.mediaTypes|languages|
charsets|encodings([STR2_ARR])#Returns REQ Accept[-Language|Charset|Encoding] [C]
->STR_ARR #If STR2_ARR, make a union (i.e. content negotiation)
NTIATOR.mediaType|language|
charset|encoding([STR2_ARR])
->STR #Same but only the first one (i.e. most preferred)
/=+===============================+=\
/ : : \
)==: ACCEPTS :==(
\ :_______________________________: /
\=+===============================+=/
VERSION ==> #1.3.8
#Uses NEGOTIATOR
new Accepts(REQ) #
ACCEPTS.type[s]|language[s]| #Like NEGOTIATOR except:
charset[s]|encoding[s] # - different API signature:
([STR2_ARR],...) # - return STR if STR2_ARR provided, STR_ARR otherwise
->STR[_ARR]|false # - can use several args,...
# - returns false instead of undefined
# - 'MIME2' can be TYPE/*, EXT, etc.
# - returns 'TYPE/*', EXT, etc. as is