def redirect.against
emerging-ezhttp@0.21.0.0 · src/redirect.bend:230
import emerging-ezhttp@0.21.0.0/src/redirect.bend as Redirect
import Base
230
231def redirect.against(scheme: String, host: String, port: U32, path: String,
232 +loc: String, k: Sort) -> Maybe<&2, String>:
233 match k:
234 case Net{}:
235 Some{scheme ++ ":" ++ loc}
236 case Abs{}:
237 Some{scheme ++ "://" ++ host ++ ":" ++ U32.show(port)
238 ++ redirect.abs.of(redirect.split(loc))}
239 case Stay{}:
240 None{}
241 case Query{}:
242 Some{scheme ++ "://" ++ host ++ ":" ++ U32.show(port)
243 ++ redirect.base(path) ++ loc}
244 case Rel{}:
245 Some{scheme ++ "://" ++ host ++ ":" ++ U32.show(port)
246 ++ redirect.rel.of(redirect.base(path), redirect.split(loc))}