Route.bend checks
raw source on the hub · import 0x23d6c01e38291fa6120695d15d993373/Route.bend as Route
4 imports
import Base import hhefesto-wire@1.0.0.0/Wire.bend as W import hhefesto-json@1.0.0.0/Json.bend as J import hhefesto-json@1.0.0.0/Codec.bend as C
Types
type rt.Ty source · line 33 · raw
Data
What a capture or a query parameter holds: a natural number, an integer (servant's Int), text, a decimal (servant's Double)
rt.TNatrt.Ty
rt.TIntrt.Ty
rt.TTextrt.Ty
rt.TNumrt.Ty
type rt.Int source · line 40 · raw
Data
an integer: its sign and size
rt.Int@neg:Bool -> @n:Nat -> rt.Int
type rt.Api source · line 43 · raw
Data
rt.Seg@s:String -> @k:rt.Api -> rt.Api
rt.Cap@name:String -> @t:rt.Ty -> @k:rt.Api -> rt.Api
rt.Qry@name:String -> @t:rt.Ty -> @k:rt.Api -> rt.Api
rt.Hdr@name:String -> @k:rt.Api -> rt.Api
rt.Peer@k:rt.Api -> rt.Api
rt.Body@s:0xd8afce72fe33721bc84d5535590f151d/Codec.js.Sh -> @k:rt.Api -> rt.Api
rt.Bytes@k:rt.Api -> rt.Api
rt.Verb@m:String -> @s:0xd8afce72fe33721bc84d5535590f151d/Codec.js.Sh -> rt.Api
rt.Rawrt.Api
rt.Alt@a:rt.Api -> @b:rt.Api -> rt.Api
rt.Nothingrt.Api
type rt.Reply source · line 58 · raw
@-A:Data -> Data
What a handler answers: a value (200, as JSON), with headers, or an error (servant's throwError): a status, headers and a body.
rt.Ok@-A:Data -> @hs:List<&2, 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.H> -> @v:A -> rt.Reply<A>
rt.Err@-A:Data -> @status:U32 -> @hs:List<&2, 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.H> -> @body:String -> rt.Reply<A>
type rt.Why source · line 63 · raw
Data
Why an alternative missed, from least to most telling (servant's order).
rt.NotFoundrt.Why
rt.NotAllowedrt.Why
rt.Unsupportedrt.Why
rt.Unread@msg:String -> rt.Why
type rt.Res source · line 69 · raw
@-A:Data -> Data
rt.No@-A:Data -> @why:rt.Why -> rt.Res<A>
rt.Bad@-A:Data -> @msg:String -> rt.Res<A>
rt.Hit@-A:Data -> @v:A -> rt.Res<A>
type rt.Dec source · line 155 · raw
Data
Decimal digits: the value, and what is left after them (Data.Text.Read's decimal).
rt.Dec@n:Nat -> @rest:String -> rt.Dec
Definitions
def rt.if source · line 76 · raw
@-A:Data -> @b:Bool -> @t:(@_:Unit -> A) -> @e:(@_:Unit -> A) -> A
a choice whose branches are computed only when taken (Bool.pick computes both)
def rt.TVal source · line 86 · raw
@t:rt.Ty -> Data
def rt.In source · line 97 · raw
@a:rt.Api -> Data
def rt.Server source · line 122 · raw
@a:rt.Api -> Type
def rt.unparsed source · line 150 · raw
@+s:String -> @more:String -> String
def rt.dec.at source · line 158 · raw
@d:Maybe<&2, 0xd8afce72fe33721bc84d5535590f151d/Json.js.D> -> @+n:Nat -> @h:Char -> @t:String -> @more:(@_:Nat -> rt.Dec) -> rt.Dec
def rt.dec.go source · line 165 · raw
@cs:String -> @+n:Nat -> rt.Dec
def rt.nat.fin source · line 172 · raw
@+s:String -> @d:rt.Dec -> Result<&2, &2, String, Nat>
def rt.nat.first source · line 179 · raw
@m:Maybe<&2, 0xd8afce72fe33721bc84d5535590f151d/Json.js.D> -> @+s:String -> @ds:String -> Result<&2, &2, String, Nat>
def rt.nat.read source · line 187 · raw
@+s:String -> @ds:String -> Result<&2, &2, String, Nat>
a natural number in decimal, the whole of s (ds: what is left of s)
def rt.int.sign source · line 194 · raw
@neg:Bool -> @r:Result<&2, &2, String, Nat> -> Result<&2, &2, String, rt.Int>
def rt.int.at source · line 201 · raw
@minus:Bool -> @plus:Bool -> @+s:String -> @t:String -> Result<&2, &2, String, rt.Int>
def rt.int.read source · line 211 · raw
@+s:String -> Result<&2, &2, String, rt.Int>
an integer: a sign ("-", "+" or none), then decimal digits
def rt.num.got source · line 218 · raw
@+s:String -> @m:Maybe<&2, 0xd8afce72fe33721bc84d5535590f151d/Json.js.Json> -> Result<&2, &2, String, 0xd8afce72fe33721bc84d5535590f151d/Json.js.Num>
def rt.num.first source · line 225 · raw
@m:Maybe<&2, 0xd8afce72fe33721bc84d5535590f151d/Json.js.D> -> @minus:Bool -> @+s:String -> Result<&2, &2, String, 0xd8afce72fe33721bc84d5535590f151d/Json.js.Num>
def rt.num.read source · line 233 · raw
@+s:String -> Result<&2, &2, String, 0xd8afce72fe33721bc84d5535590f151d/Json.js.Num>
a decimal (as JSON writes one)
def rt.parse source · line 241 · raw
@t:rt.Ty -> @+s:String -> Result<&2, &2, String, rt.TVal(t)>
A value of a type read from text (a capture's segment, a parameter's value)
def rt.print source · line 253 · raw
@t:rt.Ty -> @v:rt.TVal(t) -> String
and written back as text
def rt.why.max source · line 268 · raw
@a:rt.Why -> @b:rt.Why -> rt.Why
servant's order of misses: keep the first unless the second tells more
def rt.alt.second source · line 283 · raw
@-A:Data -> @-B:Data -> @w:rt.Why -> @r:rt.Res<B> -> rt.Res<Either<&2, &2, A, B>>
def rt.alt source · line 293 · raw
@-A:Data -> @-B:Data -> @r:rt.Res<A> -> @more:(@_:Unit -> rt.Res<B>) -> rt.Res<Either<&2, &2, A, B>>
a, else b: the first hit, or the first final error, or the more telling miss
def rt.seg.at source · line 302 · raw
@-A:Data -> @hit:Bool -> @more:(@_:Unit -> rt.Res<A>) -> rt.Res<A>
def rt.input source · line 310 · raw
@-V:Data -> @-K:Data -> @rest:rt.Res<K> -> @r:Result<&2, &2, String, V> -> rt.Res<0xd8afce72fe33721bc84d5535590f151d/Codec.js.P<V, K>>
an input read where the rest of the API hits: its error, the rest's, or both
def rt.cap.at source · line 321 · raw
@-V:Data -> @-K:Data -> @+name:String -> @r:Result<&2, &2, String, V> -> @more:(@_:Unit -> rt.Res<K>) -> rt.Res<0xd8afce72fe33721bc84d5535590f151d/Codec.js.P<V, K>>
def rt.qparse.got source · line 328 · raw
@+name:String -> @-t:rt.Ty -> @r:Result<&2, &2, String, rt.TVal(t)> -> Result<&2, &2, String, Maybe<&2, rt.TVal(t)>>
def rt.qparse source · line 335 · raw
@+name:String -> @+t:rt.Ty -> @m:Maybe<&2, String> -> Result<&2, &2, String, Maybe<&2, rt.TVal(t)>>
def rt.hdr source · line 342 · raw
@hs:List<&2, 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.H> -> @+name:String -> Maybe<&2, String>
def rt.mime.cut source · line 349 · raw
@ps:List<&2, String> -> String
def rt.mime source · line 357 · raw
@+hs:List<&2, 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.H> -> String
the request's media type (before any ";"), lower case; "" none
def rt.body.in source · line 360 · raw
@-V:Data -> @-K:Data -> @ok:Bool -> @rest:rt.Res<K> -> @r:Result<&2, &2, String, V> -> rt.Res<0xd8afce72fe33721bc84d5535590f151d/Codec.js.P<V, K>>
def rt.json.got source · line 369 · raw
@-sh:0xd8afce72fe33721bc84d5535590f151d/Codec.js.Sh -> @m:Maybe<&2, 0xd8afce72fe33721bc84d5535590f151d/Codec.js.Val(sh)> -> Result<&2, &2, String, 0xd8afce72fe33721bc84d5535590f151d/Codec.js.Val(sh)>
def rt.req.path source · line 376 · raw
@r:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> @ps:List<&2, String> -> 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req
def rt.done source · line 381 · raw
@ps:List<&2, String> -> Bool
def rt.verb.at source · line 390 · raw
@done:Bool -> @ok:Bool -> rt.Res<Unit>
def rt.method.ok source · line 399 · raw
@+want:String -> @+m:String -> Bool
def rt.go source · line 403 · raw
@+a:rt.Api -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> @+ps:List<&2, String> -> rt.Res<rt.In(a)>
What a request means to an API, its path still to go being ps.
def rt.route source · line 435 · raw
@+a:rt.Api -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> rt.Res<rt.In(a)>
a request read by an API
def rt.json.type source · line 441 · raw
0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.H
def rt.render source · line 444 · raw
@+sh:0xd8afce72fe33721bc84d5535590f151d/Codec.js.Sh -> @r:rt.Reply<0xd8afce72fe33721bc84d5535590f151d/Codec.js.Val(sh)> -> 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp
def rt.answer source · line 451 · raw
@+sh:0xd8afce72fe33721bc84d5535590f151d/Codec.js.Sh -> @io:IO(rt.Reply<0xd8afce72fe33721bc84d5535590f151d/Codec.js.Val(sh)>) -> IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)
def rt.apply source · line 457 · raw
@+a:rt.Api -> @s:rt.Server(a) -> @i:rt.In(a) -> IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)
what serves an API, given what a request gave it
def rt.miss source · line 484 · raw
@w:rt.Why -> 0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp
def rt.fin source · line 495 · raw
@+a:rt.Api -> @s:rt.Server(a) -> @r:rt.Res<rt.In(a)> -> IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)
def rt.serve source · line 505 · raw
@+a:rt.Api -> @s:rt.Server(a) -> @+req:0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Req -> IO(0xb8e08f92b233e37463500e01c2e5b973/Wire.wr.Resp)
A request served: read by the API, then answered by the server
def rt.ty.name source · line 511 · raw
@t:rt.Ty -> String
def rt.docs source · line 524 · raw
@a:rt.Api -> @+path:String -> @+more:String -> List<&2, String>
Each endpoint as a line: its method, path (":name" a capture), query parameters and what else it reads.