Last change
on this file since 325 was 325, checked in by alloc, 7 years ago |
Code style cleanup (mostly whitespace changes, enforcing braces, using cleanup)
|
File size:
1.0 KB
|
Rev | Line | |
---|
[230] | 1 | using System.Net;
|
---|
| 2 | using System.Text;
|
---|
[325] | 3 | using AllocsFixes.JSON;
|
---|
[230] | 4 |
|
---|
[325] | 5 | namespace AllocsFixes.NetConnections.Servers.Web.API {
|
---|
| 6 | public abstract class WebAPI {
|
---|
| 7 | public static void WriteJSON (HttpListenerResponse resp, JSONNode root) {
|
---|
[309] | 8 | StringBuilder sb = new StringBuilder ();
|
---|
| 9 | root.ToString (sb);
|
---|
| 10 | byte[] buf = Encoding.UTF8.GetBytes (sb.ToString ());
|
---|
[230] | 11 | resp.ContentLength64 = buf.Length;
|
---|
| 12 | resp.ContentType = "application/json";
|
---|
| 13 | resp.ContentEncoding = Encoding.UTF8;
|
---|
| 14 | resp.OutputStream.Write (buf, 0, buf.Length);
|
---|
| 15 | }
|
---|
| 16 |
|
---|
[325] | 17 | public static void WriteText (HttpListenerResponse _resp, string _text) {
|
---|
[306] | 18 | byte[] buf = Encoding.UTF8.GetBytes (_text);
|
---|
| 19 | _resp.ContentLength64 = buf.Length;
|
---|
| 20 | _resp.ContentType = "text/plain";
|
---|
| 21 | _resp.ContentEncoding = Encoding.UTF8;
|
---|
| 22 | _resp.OutputStream.Write (buf, 0, buf.Length);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
[325] | 25 | public abstract void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user,
|
---|
| 26 | int permissionLevel);
|
---|
[279] | 27 |
|
---|
| 28 | public virtual int DefaultPermissionLevel () {
|
---|
| 29 | return 0;
|
---|
| 30 | }
|
---|
[230] | 31 | }
|
---|
[325] | 32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.