Rev | Line | |
---|
[230] | 1 | using System;
|
---|
| 2 | using System.Net;
|
---|
| 3 | using System.Text;
|
---|
| 4 |
|
---|
| 5 | namespace AllocsFixes.NetConnections.Servers.Web.API
|
---|
| 6 | {
|
---|
| 7 | public abstract class WebAPI
|
---|
| 8 | {
|
---|
[306] | 9 | public static void WriteJSON (HttpListenerResponse resp, JSON.JSONNode root)
|
---|
[230] | 10 | {
|
---|
| 11 | byte[] buf = Encoding.UTF8.GetBytes (root.ToString());
|
---|
| 12 | resp.ContentLength64 = buf.Length;
|
---|
| 13 | resp.ContentType = "application/json";
|
---|
| 14 | resp.ContentEncoding = Encoding.UTF8;
|
---|
| 15 | resp.OutputStream.Write (buf, 0, buf.Length);
|
---|
| 16 | }
|
---|
| 17 |
|
---|
[306] | 18 | public static void WriteText (HttpListenerResponse _resp, string _text)
|
---|
| 19 | {
|
---|
| 20 | byte[] buf = Encoding.UTF8.GetBytes (_text);
|
---|
| 21 | _resp.ContentLength64 = buf.Length;
|
---|
| 22 | _resp.ContentType = "text/plain";
|
---|
| 23 | _resp.ContentEncoding = Encoding.UTF8;
|
---|
| 24 | _resp.OutputStream.Write (buf, 0, buf.Length);
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[244] | 27 | public abstract void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel);
|
---|
[279] | 28 |
|
---|
| 29 | public virtual int DefaultPermissionLevel () {
|
---|
| 30 | return 0;
|
---|
| 31 | }
|
---|
[230] | 32 | }
|
---|
| 33 | }
|
---|
| 34 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.