darklang / dark

Darklang main repo, including language, backend, and infra
https://darklang.com
Other
1.69k stars 91 forks source link

Component: HttpClient #4707

Open StachuDotNet opened 1 year ago

StachuDotNet commented 1 year ago

Dark avails a base Http client, for making calls to endpoints across the internet. This issue organies varios improvements to, and testing of, the HttpClient and its surrounding helper functions.

These tasks are largely unblocked, and accessible to anyone interested.

This needs notable organization, clearly.

StachuDotNet commented 9 months ago

quick thoughts on making httpclient calls 'safe' and enabling a user to either

I suppose this is most similar to having a DB-accessing function take a DbRef, and passing that DbRef down 'from the top'.

first, note that URLs look roughly like:

so, define some types like

type SchemeRule = 
    | AnyScheme
    | SpecificScheme of string

type AuthorityRule = 
    | AnyAuthority
    | SpecificDomain of string
    | AnySubdomainOf of string

type PathRule = 
    | AnyPath
    | StartsWith of string
    | EqualsTo of string

type QueryRule = 
    | AnyQuery
    | ContainsKey of string
    | KeyValue of string * string

type FragmentRule = 
    | AnyFragment
    | FragmentEquals of string

type UrlRule = {
    Scheme: SchemeRule
    Authority: AuthorityRule
    Path: PathRule
    Query: QueryRule
    Fragment: FragmentRule
}

let exampleUsage = {
    Scheme = SpecificScheme "https"
    Authority = AnySubdomainOf "google.com"
    Path = AnyPath
    Query = AnyQuery
    Fragment = AnyFragment
}

and from there, it feels like there are a few ways to use those types to provide info/security: