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 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
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 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
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 |
NewerOlder