| 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 | {
|
|---|
| [309] | 11 | StringBuilder sb = new StringBuilder ();
|
|---|
| 12 | root.ToString (sb);
|
|---|
| 13 | byte[] buf = Encoding.UTF8.GetBytes (sb.ToString ());
|
|---|
| [230] | 14 | resp.ContentLength64 = buf.Length;
|
|---|
| 15 | resp.ContentType = "application/json";
|
|---|
| 16 | resp.ContentEncoding = Encoding.UTF8;
|
|---|
| 17 | resp.OutputStream.Write (buf, 0, buf.Length);
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| [306] | 20 | public static void WriteText (HttpListenerResponse _resp, string _text)
|
|---|
| 21 | {
|
|---|
| 22 | byte[] buf = Encoding.UTF8.GetBytes (_text);
|
|---|
| 23 | _resp.ContentLength64 = buf.Length;
|
|---|
| 24 | _resp.ContentType = "text/plain";
|
|---|
| 25 | _resp.ContentEncoding = Encoding.UTF8;
|
|---|
| 26 | _resp.OutputStream.Write (buf, 0, buf.Length);
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| [244] | 29 | public abstract void HandleRequest (HttpListenerRequest req, HttpListenerResponse resp, WebConnection user, int permissionLevel);
|
|---|
| [279] | 30 |
|
|---|
| 31 | public virtual int DefaultPermissionLevel () {
|
|---|
| 32 | return 0;
|
|---|
| 33 | }
|
|---|
| [230] | 34 | }
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.