Reworked a lot of how REST works

This commit is contained in:
Lucas Nicodemus 2011-09-04 23:06:43 -06:00
parent d824e71507
commit d7012bd094
3 changed files with 58 additions and 22 deletions

View file

@ -69,7 +69,7 @@ namespace TShockAPI
public static bool OverridePort;
public static PacketBufferer PacketBuffer;
public static MaxMind.GeoIPCountry Geo;
public static Rest RestApi;
public static RestManager RestApi;
/// <summary>
/// Called after TShock is initialized. Useful for plugins that needs hooks before tshock but also depend on tshock being loaded.
@ -175,7 +175,7 @@ namespace TShockAPI
Regions = new RegionManager(DB);
Itembans = new ItemManager(DB);
RememberedPos = new RemeberedPosManager(DB);
RestApi = new Rest(IPAddress.Any, 8080);
RestApi = new RestManager(new Rest(IPAddress.Any, 8080));
if (Config.EnableGeoIP)
Geo = new MaxMind.GeoIPCountry(Path.Combine(SavePath, "GeoIP.dat"));
@ -205,7 +205,8 @@ namespace TShockAPI
if (Initialized != null)
Initialized();
RestApi.Register(new RestCommand("/HelloWorld/name/{username}", usertest));
RestApi.RegisterRestfulCommands();
}
catch (Exception ex)
{
@ -236,24 +237,6 @@ namespace TShockAPI
//RconHandler.ShutdownAllThreads();
}
//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;
}
/// <summary>
/// Handles exceptions that we didn't catch or that Red fucked up
/// </summary>