You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 31, 2024. It is now read-only.
I've based my backend app on some of the code I've found in your solution, and I wanted to share a couple of improvements that Dave Shaw and gsomix on the F# Slack helped me with. I liked what you were doing with PrintfFormat in the UrlPaths module, but I didn't like that I couldn't use it with sprintf to remove the path duplication in the Url module. The following code fixes that.
moduleUrlPaths =// The type aliases are both more readable, but also allows the format to work with both// routef and sprintftypeStringPath= PrintfFormat<string -> string, unit, string, string, string>typeStringPath2= PrintfFormat<string -> string -> string, unit, string, string, string * string>let ``/api/foo`` ="/api/mil-to-mil/cost-categories"let ``/api/foo/%s`` :StringPath ="/api/mil-to-mil/cost-categories/%s"moduleUrl =letcreate(baseUrl :string)(route :string)=
route.TrimStart [|'/'|]|> sprintf "%s/%s" baseUrl
let ``/api/foo/%s`` baseUrl fooId = create baseUrl (sprintf UrlPaths.``/api/foo/%s`` fooId)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I've based my backend app on some of the code I've found in your solution, and I wanted to share a couple of improvements that Dave Shaw and gsomix on the F# Slack helped me with. I liked what you were doing with
PrintfFormat
in the UrlPaths module, but I didn't like that I couldn't use it withsprintf
to remove the path duplication in the Url module. The following code fixes that.The text was updated successfully, but these errors were encountered: