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:
@ -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);
|
||||
}
|
||||
|
@ -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")]
|
||||
|
Reference in New Issue
Block a user