This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new_user(admin_username, admin_password): | |
env.user = 'root' | |
# Create the admin group and add it to the sudoers file | |
admin_group = 'admin' | |
runcmd('addgroup {group}'.format(group=admin_group)) | |
runcmd('echo "%{group} ALL=(ALL) ALL" >> /etc/sudoers'.format( | |
group=admin_group)) | |
# Create the new admin user (default group=username); add to admin group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PngProcessor : MediaTypeProcessor | |
{ | |
public PngProcessor(HttpOperationDescription operation, | |
MediaTypeProcessorMode mode) : base (operation, mode) | |
{ | |
} | |
public override IEnumerable< string > SupportedMediaTypes | |
{ | |
get |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void Application_Start(object sender, EventArgs e) | |
{ | |
var configuration = new ContactManagerConfiguration(); | |
RouteTable.Routes.AddServiceRoute<ContactResource>( “contact“, configuration); | |
RouteTable.Routes.AddServiceRoute<ContactsResource>( “contacts“, configuration); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ContactManagerConfiguration : HostConfiguration | |
{ | |
public override void RegisterRequestProcessorsForOperation( HttpOperationDescription operation, | |
IList<Processor> processors, MediaTypeProcessorMode mode) | |
{ | |
processors.Add(new JsonProcessor(operation, mode)); | |
processors.Add(new FormUrlEncodedProcessor(operation, mode)); | |
} | |
public override void RegisterResponseProcessorsForOperation( HttpOperationDescription operation, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ServiceContract] | |
public class ContactsResource | |
{ | |
private static int nextId = 1; | |
[WebInvoke(UriTemplate = "", Method = "POST")] | |
public JsonValue Post(JsonValue contact) | |
{ | |
var postedContact = (dynamic)contact; | |
var contactResponse = (dynamic)new JsonObject(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JsonValueSampleConfiguration : HostConfiguration | |
{ | |
public override void RegisterRequestProcessorsForOperation( HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) | |
{ | |
processors.Add(new FormUrlEncodedProcessor(operation, mode)); | |
} | |
public override void RegisterResponseProcessorsForOperation( HttpOperationDescription operation, IList<Processor> processors, MediaTypeProcessorMode mode) | |
{ | |
processors.ClearMediaTypeProcessors(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[WebGet(UriTemplate = "")] | |
[QueryComposition] | |
public IEnumerable<Contact> Get() | |
{ | |
return contacts.AsQueryable(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public IEnumerable<Order> GetApprovedOrders() | |
{ | |
string address = "http://contoso.com/orders"; | |
HttpClient client = new HttpClient(address); | |
WebQuery<Order> orders = client.CreateQuery<Contact>(); | |
return orders.Where<Order>(o=>o.State == OrderState.Approved). OrderBy(o=o.OrderID); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ServiceContract] | |
public class HelloWorldResource { | |
[WebGet(UriTemplate="")] | |
public void Get(HttpRequestMessage req, HttpResponseMessage resp) { | |
if (req.IfNoneMatch.Contains("HW")) { | |
resp.StatusCode = HttpStatusCode.NotModified; | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ServiceContract] | |
public class DocumentResource | |
{ | |
[WebGet(UriTemplate="{name}")] | |
public Document Get(string name, HttpResponseMessage resp) | |
{ | |
Document doc; |
OlderNewer