Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
SchlenkR committed Dec 24, 2023
1 parent cdf8fdc commit 1ffe5ee
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 77 deletions.
132 changes: 88 additions & 44 deletions src/FsHttp/Dsl.CE.fs
Original file line number Diff line number Diff line change
Expand Up @@ -37,37 +37,45 @@ let http = { config = None }
type IRequestContext<'self> with

[<CustomOperation("Method")>]
member this.Method(_: IRequestContext<StartingContext>, method, url) = Http.method method url
member this.Method(_: IRequestContext<StartingContext>, method, url) =
Http.method method url

// RFC 2626 specifies 8 methods
[<CustomOperation("GET")>]
member this.Get(context: IRequestContext<StartingContext>, url) = getWithConfig context.Self.ActualConfig url
member this.Get(context: IRequestContext<StartingContext>, url) =
getWithConfig context.Self.ActualConfig url

[<CustomOperation("PUT")>]
member this.Put(context: IRequestContext<StartingContext>, url) = putWithConfig context.Self.ActualConfig url
member this.Put(context: IRequestContext<StartingContext>, url) =
putWithConfig context.Self.ActualConfig url

[<CustomOperation("POST")>]
member this.Post(context: IRequestContext<StartingContext>, url) = postWithConfig context.Self.ActualConfig url
member this.Post(context: IRequestContext<StartingContext>, url) =
postWithConfig context.Self.ActualConfig url

[<CustomOperation("DELETE")>]
member this.Delete(context: IRequestContext<StartingContext>, url) = deleteWithConfig context.Self.ActualConfig url
member this.Delete(context: IRequestContext<StartingContext>, url) =
deleteWithConfig context.Self.ActualConfig url

[<CustomOperation("OPTIONS")>]
member this.Options(context: IRequestContext<StartingContext>, url) =
optionsWithConfig context.Self.ActualConfig url

[<CustomOperation("HEAD")>]
member this.Head(context: IRequestContext<StartingContext>, url) = headWithConfig context.Self.ActualConfig url
member this.Head(context: IRequestContext<StartingContext>, url) =
headWithConfig context.Self.ActualConfig url

[<CustomOperation("TRACE")>]
member this.Trace(context: IRequestContext<StartingContext>, url) = traceWithConfig context.Self.ActualConfig url
member this.Trace(context: IRequestContext<StartingContext>, url) =
traceWithConfig context.Self.ActualConfig url

[<CustomOperation("CONNECT")>]
member this.Connect(context: IRequestContext<StartingContext>, url) =
connectWithConfig context.Self.ActualConfig url

[<CustomOperation("PATCH")>]
member this.Patch(context: IRequestContext<StartingContext>, url) = patchWithConfig context.Self.ActualConfig url
member this.Patch(context: IRequestContext<StartingContext>, url) =
patchWithConfig context.Self.ActualConfig url


// ---------
Expand All @@ -78,19 +86,23 @@ type IRequestContext<'self> with

/// Append query params
[<CustomOperation("query")>]
member this.Query(context: IRequestContext<HeaderContext>, queryParams) = Header.query queryParams context.Self
member this.Query(context: IRequestContext<HeaderContext>, queryParams) =
Header.query queryParams context.Self

/// Custom headers
[<CustomOperation("headers")>]
member this.Headers(context: IRequestContext<HeaderContext>, headers) = Header.headers headers context.Self
member this.Headers(context: IRequestContext<HeaderContext>, headers) =
Header.headers headers context.Self

/// Custom header
[<CustomOperation("header")>]
member this.Header(context: IRequestContext<HeaderContext>, key, value) = Header.header key value context.Self
member this.Header(context: IRequestContext<HeaderContext>, key, value) =
Header.header key value context.Self

/// Content-Types that are acceptable for the response
[<CustomOperation("Accept")>]
member this.Accept(context: IRequestContext<HeaderContext>, contentType) = Header.accept contentType context.Self
member this.Accept(context: IRequestContext<HeaderContext>, contentType) =
Header.accept contentType context.Self

/// Character sets that are acceptable
[<CustomOperation("AcceptCharset")>]
Expand Down Expand Up @@ -139,7 +151,8 @@ type IRequestContext<'self> with

/// An HTTP cookie previously sent by the server with 'Set-Cookie'.
[<CustomOperation("Cookie")>]
member this.SetCookie(context: IRequestContext<HeaderContext>, name, value) = Header.cookie name value context.Self
member this.SetCookie(context: IRequestContext<HeaderContext>, name, value) =
Header.cookie name value context.Self

/// An HTTP cookie previously sent by the server with 'Set-Cookie' with
/// the subset of URIs on the origin server to which this Cookie applies.
Expand All @@ -156,29 +169,35 @@ type IRequestContext<'self> with

/// The date and time that the message was sent
[<CustomOperation("Date")>]
member this.Date(context: IRequestContext<HeaderContext>, date) = Header.date date context.Self
member this.Date(context: IRequestContext<HeaderContext>, date) =
Header.date date context.Self

/// Indicates that particular server behaviors are required by the client
[<CustomOperation("Expect")>]
member this.Expect(context: IRequestContext<HeaderContext>, behaviors) = Header.expect behaviors context.Self
member this.Expect(context: IRequestContext<HeaderContext>, behaviors) =
Header.expect behaviors context.Self

/// Gives the date/time after which the response is considered stale
[<CustomOperation("Expires")>]
member this.Expires(context: IRequestContext<HeaderContext>, dateTime) = Header.expires dateTime context.Self
member this.Expires(context: IRequestContext<HeaderContext>, dateTime) =
Header.expires dateTime context.Self

/// The email address of the user making the request
[<CustomOperation("From")>]
member this.From(context: IRequestContext<HeaderContext>, email) = Header.from email context.Self
member this.From(context: IRequestContext<HeaderContext>, email) =
Header.from email context.Self

/// The domain name of the server (for virtual hosting), and the TCP port number on which the server is listening.
/// The port number may be omitted if the port is the standard port for the service requested.
[<CustomOperation("Host")>]
member this.Host(context: IRequestContext<HeaderContext>, host) = Header.host host context.Self
member this.Host(context: IRequestContext<HeaderContext>, host) =
Header.host host context.Self

/// Only perform the action if the client supplied entity matches the same entity on the server.
/// This is mainly for methods like PUT to only update a resource if it has not been modified since the user last updated it. If-Match: "737060cd8c284d8af7ad3082f209582d" Permanent
[<CustomOperation("IfMatch")>]
member this.IfMatch(context: IRequestContext<HeaderContext>, entity) = Header.ifMatch entity context.Self
member this.IfMatch(context: IRequestContext<HeaderContext>, entity) =
Header.ifMatch entity context.Self

/// Allows a 304 Not Modified to be returned if content is unchanged
[<CustomOperation("IfModifiedSince")>]
Expand All @@ -187,11 +206,13 @@ type IRequestContext<'self> with

/// Allows a 304 Not Modified to be returned if content is unchanged
[<CustomOperation("IfNoneMatch")>]
member this.IfNoneMatch(context: IRequestContext<HeaderContext>, etag) = Header.ifNoneMatch etag context.Self
member this.IfNoneMatch(context: IRequestContext<HeaderContext>, etag) =
Header.ifNoneMatch etag context.Self

/// If the entity is unchanged, send me the part(s) that I am missing; otherwise, send me the entire new entity
[<CustomOperation("IfRange")>]
member this.IfRange(context: IRequestContext<HeaderContext>, range) = Header.ifRange range context.Self
member this.IfRange(context: IRequestContext<HeaderContext>, range) =
Header.ifRange range context.Self

/// Only send the response if the entity has not been modified since a specific time
[<CustomOperation("IfUnmodifiedSince")>]
Expand All @@ -200,7 +221,8 @@ type IRequestContext<'self> with

/// Specifies a parameter used into order to maintain a persistent connection
[<CustomOperation("KeepAlive")>]
member this.KeepAlive(context: IRequestContext<HeaderContext>, keepAlive) = Header.keepAlive keepAlive context.Self
member this.KeepAlive(context: IRequestContext<HeaderContext>, keepAlive) =
Header.keepAlive keepAlive context.Self

/// Specifies the date and time at which the accompanying body data was last modified
[<CustomOperation("LastModified")>]
Expand All @@ -209,19 +231,23 @@ type IRequestContext<'self> with

/// Limit the number of times the message can be forwarded through proxies or gateways
[<CustomOperation("MaxForwards")>]
member this.MaxForwards(context: IRequestContext<HeaderContext>, count) = Header.maxForwards count context.Self
member this.MaxForwards(context: IRequestContext<HeaderContext>, count) =
Header.maxForwards count context.Self

/// Initiates a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response header)
[<CustomOperation("Origin")>]
member this.Origin(context: IRequestContext<HeaderContext>, origin) = Header.origin origin context.Self
member this.Origin(context: IRequestContext<HeaderContext>, origin) =
Header.origin origin context.Self

/// Implementation-specific headers that may have various effects anywhere along the request-response chain.
[<CustomOperation("Pragma")>]
member this.Pragma(context: IRequestContext<HeaderContext>, pragma) = Header.pragma pragma context.Self
member this.Pragma(context: IRequestContext<HeaderContext>, pragma) =
Header.pragma pragma context.Self

/// Optional instructions to the server to control request processing. See RFC https://tools.ietf.org/html/rfc7240 for more details
[<CustomOperation("Prefer")>]
member this.Prefer(context: IRequestContext<HeaderContext>, prefer) = Header.prefer prefer context.Self
member this.Prefer(context: IRequestContext<HeaderContext>, prefer) =
Header.prefer prefer context.Self

/// Authorization credentials for connecting to a proxy.
[<CustomOperation("ProxyAuthorization")>]
Expand All @@ -230,22 +256,26 @@ type IRequestContext<'self> with

/// Request only part of an entity. Bytes are numbered from 0
[<CustomOperation("Range")>]
member this.Range(context: IRequestContext<HeaderContext>, start, finish) = Header.range start finish context.Self
member this.Range(context: IRequestContext<HeaderContext>, start, finish) =
Header.range start finish context.Self

/// This is the address of the previous web page from which a link to the currently requested page was followed.
/// (The word "referrer" is misspelled in the RFC as well as in most implementations.)
[<CustomOperation("Referer")>]
member this.Referer(context: IRequestContext<HeaderContext>, referer) = Header.referer referer context.Self
member this.Referer(context: IRequestContext<HeaderContext>, referer) =
Header.referer referer context.Self

/// The transfer encodings the user agent is willing to accept: the same values as for the response header
/// Transfer-Encoding can be used, plus the "trailers" value (related to the "chunked" transfer method) to
/// notify the server it expects to receive additional headers (the trailers) after the last, zero-sized, chunk.
[<CustomOperation("TE")>]
member this.TE(context: IRequestContext<HeaderContext>, te) = Header.te te context.Self
member this.TE(context: IRequestContext<HeaderContext>, te) =
Header.te te context.Self

/// The Trailer general field value indicates that the given set of header fields is present in the trailer of a message encoded with chunked transfer-coding
[<CustomOperation("Trailer")>]
member this.Trailer(context: IRequestContext<HeaderContext>, trailer) = Header.trailer trailer context.Self
member this.Trailer(context: IRequestContext<HeaderContext>, trailer) =
Header.trailer trailer context.Self

/// The TransferEncoding header indicates the form of encoding used to safely transfer the entity to the user.
/// The valid directives are one of: chunked, compress, deflate, gzip, orentity.
Expand All @@ -255,23 +285,28 @@ type IRequestContext<'self> with

/// Microsoft extension to the HTTP specification used in conjunction with WebDAV functionality.
[<CustomOperation("Translate")>]
member this.Translate(context: IRequestContext<HeaderContext>, translate) = Header.translate translate context.Self
member this.Translate(context: IRequestContext<HeaderContext>, translate) =
Header.translate translate context.Self

/// Specifies additional communications protocols that the client supports.
[<CustomOperation("Upgrade")>]
member this.Upgrade(context: IRequestContext<HeaderContext>, upgrade) = Header.upgrade upgrade context.Self
member this.Upgrade(context: IRequestContext<HeaderContext>, upgrade) =
Header.upgrade upgrade context.Self

/// The user agent string of the user agent
[<CustomOperation("UserAgent")>]
member this.UserAgent(context: IRequestContext<HeaderContext>, userAgent) = Header.userAgent userAgent context.Self
member this.UserAgent(context: IRequestContext<HeaderContext>, userAgent) =
Header.userAgent userAgent context.Self

/// Informs the server of proxies through which the request was sent
[<CustomOperation("Via")>]
member this.Via(context: IRequestContext<HeaderContext>, server) = Header.via server context.Self
member this.Via(context: IRequestContext<HeaderContext>, server) =
Header.via server context.Self

/// A general warning about possible problems with the entity body
[<CustomOperation("Warning")>]
member this.Warning(context: IRequestContext<HeaderContext>, message) = Header.warning message context.Self
member this.Warning(context: IRequestContext<HeaderContext>, message) =
Header.warning message context.Self

/// Override HTTP method.
[<CustomOperation("XHTTPMethodOverride")>]
Expand All @@ -287,23 +322,28 @@ type IRequestContext<'self> with

/// An explicit transformation from a previous context to allow for describing the request body.
[<CustomOperation("body")>]
member this.Body(context: IRequestContext<#IToBodyContext>) = context.Self.Transform()
member this.Body(context: IRequestContext<#IToBodyContext>) =
context.Self.Transform()

[<CustomOperation("content")>]
member this.Content(context: IRequestContext<BodyContext>, contentType, data) =
Body.content contentType data context.Self

[<CustomOperation("binary")>]
member this.Binary(context: IRequestContext<BodyContext>, data) = Body.binary data context.Self
member this.Binary(context: IRequestContext<BodyContext>, data) =
Body.binary data context.Self

[<CustomOperation("stream")>]
member this.Stream(context: IRequestContext<BodyContext>, stream) = Body.stream stream context.Self
member this.Stream(context: IRequestContext<BodyContext>, stream) =
Body.stream stream context.Self

[<CustomOperation("text")>]
member this.Text(context: IRequestContext<BodyContext>, text) = Body.text text context.Self
member this.Text(context: IRequestContext<BodyContext>, text) =
Body.text text context.Self

[<CustomOperation("json")>]
member this.Json(context: IRequestContext<BodyContext>, json) = Body.json json context.Self
member this.Json(context: IRequestContext<BodyContext>, json) =
Body.json json context.Self

[<CustomOperation("jsonSerializeWith")>]
member this.JsonSerializeWith(context: IRequestContext<BodyContext>, options, instance) =
Expand All @@ -314,10 +354,12 @@ type IRequestContext<'self> with
Body.jsonSerialize instance context.Self

[<CustomOperation("formUrlEncoded")>]
member this.FormUrlEncoded(context: IRequestContext<BodyContext>, data) = Body.formUrlEncoded data context.Self
member this.FormUrlEncoded(context: IRequestContext<BodyContext>, data) =
Body.formUrlEncoded data context.Self

[<CustomOperation("file")>]
member this.File(context: IRequestContext<BodyContext>, path) = Body.file path context.Self
member this.File(context: IRequestContext<BodyContext>, path) =
Body.file path context.Self

/// The type of encoding used on the data
[<CustomOperation("ContentEncoding")>]
Expand Down Expand Up @@ -350,7 +392,8 @@ type IRequestContext<'self> with

/// An explicit transformation from a previous context to allow for describing the request multiparts.
[<CustomOperation("multipart")>]
member this.Multipart(context: IRequestContext<#IToMultipartContext>) = context.Self.Transform()
member this.Multipart(context: IRequestContext<#IToMultipartContext>) =
context.Self.Transform()

[<CustomOperation("textPart")>]
member this.TextPart(context: IRequestContext<#IToMultipartContext>, value, name, ?fileName) =
Expand Down Expand Up @@ -413,7 +456,8 @@ type IRequestContext<'self> with
Config.transformHttpClientHandler transformer context.Self

[<CustomOperation("config_proxy")>]
member this.Proxy(context: IRequestContext<#IConfigure<ConfigTransformer, _>>, url) = Config.proxy url context.Self
member this.Proxy(context: IRequestContext<#IConfigure<ConfigTransformer, _>>, url) =
Config.proxy url context.Self

[<CustomOperation("config_proxyWithCredentials")>]
member this.ProxyWithCredentials(context: IRequestContext<#IConfigure<ConfigTransformer, _>>, url, credentials) =
Expand Down

0 comments on commit 1ffe5ee

Please sign in to comment.