Skip to content

Instantly share code, notes, and snippets.

@panesofglass
Created November 30, 2010 16:59
Show Gist options
  • Save panesofglass/721976 to your computer and use it in GitHub Desktop.
Save panesofglass/721976 to your computer and use it in GitHub Desktop.
.NET Web Abstractions
// Func<IRequest, IResponse>
public interface IApplication {
IAsyncResult BeginInvoke(IRequest request, AsyncCallback callback, object state);
IResponse EndInvoke(IAsyncResult result);
}
public interface IRequest {
string Method {get;}
string Uri {get;}
IDictionary<string, IEnumerable<string>> Headers {get;}
// Set custom, app-specific settings here.
IDictionary<string, object> Items {get;}
// Assume the request input is a System.IO.Stream.
IAsyncResult BeginReadInput(byte[] buffer, int offset, int count, AsyncCallback callback, object state);
int EndReadInput(IAsyncResult result);
}
public interface IResponse {
string Status {get;} // "200 OK"
IDictionary<string, IEnumerable<string>> Headers {get;}
//IEnumerable Body {get;}
IEnumerable GetBody();
}
@panesofglass
Copy link
Author

Should Header values be a simple IEnumerable instead of IEnumerable<string>?

@panesofglass
Copy link
Author

@serialseb brought up a great question: Is IMiddleware necessary? Not sure given the interfaces above. How would you chain apps together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment