Added Json flag to RouteRequest and RouteResponse to control whether or not the content is Json and needs to be handled. Updated example code. Renamed ClientCodeGenerator to RestClientGenerator. Bumped package version to 1.2.2.

This commit is contained in:
MattMo committed 2023-02-06 09:01:06 -08:00
1 parent 60768b1b3e
commit ed1d10ba9d
7 files changed
+97 -9

No files matched your search

+1 -1
View File
@@ -81,7 +81,7 @@ namespace MontoyaTech.Rest.Net.Example
var response = this.Client.HttpClient.Send(message);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
return JsonConvert.DeserializeObject<bool>(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
return bool.Parse(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
else
throw new Exception("Unexpected Http Response StatusCode:" + response.StatusCode);
}
+3 -3
View File
@@ -37,7 +37,7 @@ namespace MontoyaTech.Rest.Net.Example
new Route(HttpRequestMethod.Get, "/auth/", Json)
);
string code = ClientCodeGenerator.GenerateCSharpClient(listener.Routes);
string code = RestClientGenerator.GenerateCSharpClient(listener.Routes);
Console.WriteLine(code);
@@ -91,12 +91,12 @@ namespace MontoyaTech.Rest.Net.Example
[RouteGroup("Auth")]
[RouteName("UserExists")]
[RouteResponse(typeof(bool))]
[RouteResponse(typeof(bool), Json = false)]
public static HttpListenerResponse Exists(HttpListenerContext context, string name)
{
Console.WriteLine("Auth.Exists called, name:" + name);
return context.Response.WithStatus(HttpStatusCode.OK).WithJson(true);
return context.Response.WithStatus(HttpStatusCode.OK).WithText("true");
}
[RouteGroup("Auth")]