aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/net/http/header.lux
blob: 3a96b37fa4d5143e1851f683f7ffcb64e5a091e6 (plain)
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
(.module:
  [lux #*
   [control
    [pipe (#+ case>)]]
   [data
    [text
     format]
    [collection
     ["." dictionary (#+ Dictionary)]]]]
  [// (#+ Header)
   ["." mime (#+ MIME)]
   [// (#+ URL)]])

(def: #export (add name value)
  (-> Text Text Header)
  (dictionary.upsert name ""
                     (|>> (case>
                           ""
                           value
                           
                           previous
                           (format previous "," value)))))

(def: #export content-length
  (-> Nat Header)
  (|>> %n (..add "Content-Length")))

(def: #export content-type
  (-> MIME Header)
  (|>> mime.name (..add "Content-Type")))

(def: #export location
  (-> URL Header)
  (..add "Location"))