TShock/TShockAPI/RestManager.cs
2011-09-04 23:06:43 -06:00

52 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HttpServer;
namespace TShockAPI {
public class RestManager
{
private Rest Rest;
public RestManager(Rest rest)
{
Rest = rest;
}
public void RegisterRestfulCommands()
{
Rest.Register(new RestCommand("/HelloWorld/name/{username}", usertest));
}
#region RestMethods
//http://127.0.0.1:8080/HelloWorld/name/{username}?type=status
object usertest(Dictionary<string, string> verbs, IParameterCollection parameters, RequestEventArgs request)
{
var ret = new Dictionary<string, string>();
var type = parameters["type"];
if (type == null)
{
ret.Add("Error", "Invalid Type");
return ret;
}
if (type == "status")
{
ret.Add("Users", "Info here");
return ret;
}
return null;
}
#endregion
public void Start()
{
Rest.Start();
}
public void Dispose()
{
Rest.Dispose();
}
}
}