There are two interesting frameworks for use in Ruby and PHP that provide tools for building APIs.
Ruby: Grape https://github.com/intridea/grape/wiki
Php: Frapi http://getfrapi.com/
Does anyone know of an equivalent undertaking in .NET?
For instance, in Grape, you can create a ruby class as follows:
class MyAPI < Grape::API
prefix 'api'
get 'hello' do
{:hello => 'world'}
end
end
Which allows you to make an HTTP Request like this:
GET /api/hello
{“hello”:”world”}
That's pretty sweet.
EDIT
Upon reflection it seems as though a WCF Http Rest service might be the most similar to Frappi and Grape, which makes my question kind of silly. But I'm still hoping to collect able some projects that have tools or even some frameworks that are specific to creating APIs.
Sprache, (answered below) seems very interesting.
Kayak is a lightweight server. It let's you easily create those routes and responses:
https://github.com/kayak/kayak
From the examples:
using System;
using System.Collections.Generic;
using System.Net;
using System.Text;
using Kayak;
namespace KayakExamples
{
class Simple
{
public static void Run()
{
var server = new DotNetServer();
var pipe = server.Start();
server.Host((env, respond, error) =>
{
respond(new Tuple<string, IDictionary<string, IEnumerable<string>>, IEnumerable<object>>(
"200 OK",
new Dictionary<string, IEnumerable<string>>()
{
{ "Content-Type", new string[] { "text/html" } }
},
new object[] { Encoding.ASCII.GetBytes("Hello world.") }
));
});
Console.WriteLine("Listening on " + server.ListenEndPoint);
Console.WriteLine("Press enter to exit.");
Console.ReadLine();
pipe.Dispose();
}
}
}