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

(def: .public (has name value)
  (-> Text Text Header)
  (dictionary.revised' name ""
                       (|>> (case>
                             ""
                             value
                             
                             previous
                             (format previous "," value)))))

(def: .public content_length
  (-> Nat Header)
  (|>> %.nat (..has "Content-Length")))

(def: .public content_type
  (-> MIME Header)
  (|>> mime.name (..has "Content-Type")))

(def: .public location
  (-> URL Header)
  (..has "Location"))