forked from bonesoul/uhttpsharp
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathSomeRestController.cs
More file actions
44 lines (37 loc) · 1.38 KB
/
SomeRestController.cs
File metadata and controls
44 lines (37 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
using uhttpsharp;
namespace uhttpsharpdemo
{
class SomeRestController
{
readonly IDictionary<int, string> _strings = new Dictionary<int, string>() { { 1 , "Hahaha"}};
public Task<uhttpsharp.HttpResponse> Get(uhttpsharp.IHttpRequest request)
{
var memoryStream = new MemoryStream();
Newtonsoft.Json.JsonWriter writer = new JsonTextWriter(new StreamWriter( memoryStream));
JsonSerializer.Create().Serialize(writer, _strings);
writer.Flush();
return Task.FromResult(new HttpResponse(HttpResponseCode.Ok, "application/json; charset=utf-8", memoryStream, true));
}
public Task<uhttpsharp.HttpResponse> GetItem(uhttpsharp.IHttpRequest request)
{
throw new NotImplementedException();
}
public Task<uhttpsharp.HttpResponse> Create(uhttpsharp.IHttpRequest request)
{
throw new NotImplementedException();
}
public Task<uhttpsharp.HttpResponse> Upsert(uhttpsharp.IHttpRequest request)
{
throw new NotImplementedException();
}
public Task<uhttpsharp.HttpResponse> Delete(uhttpsharp.IHttpRequest request)
{
throw new NotImplementedException();
}
}
}