forked from Code-Sharp/uHttpSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSomeRestController.cs
More file actions
36 lines (29 loc) · 1.24 KB
/
Copy pathSomeRestController.cs
File metadata and controls
36 lines (29 loc) · 1.24 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace uhttpsharp.Demo {
internal class SomeRestController {
private readonly IDictionary<int, string> _strings = new Dictionary<int, string> {{1, "Hahaha"}};
public Task<HttpResponse> Get(IHttpRequest request) {
var memoryStream = new MemoryStream();
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<HttpResponse> GetItem(IHttpRequest request) {
throw new NotImplementedException();
}
public Task<HttpResponse> Create(IHttpRequest request) {
throw new NotImplementedException();
}
public Task<HttpResponse> Upsert(IHttpRequest request) {
throw new NotImplementedException();
}
public Task<HttpResponse> Delete(IHttpRequest request) {
throw new NotImplementedException();
}
}
}