Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and delete vhosts #14

Merged
merged 5 commits into from Apr 7, 2018
Merged

Create and delete vhosts #14

merged 5 commits into from Apr 7, 2018

Conversation

baelter
Copy link
Member

@baelter baelter commented Apr 6, 2018

No description provided.

@baelter baelter changed the title Simple working implementation of policies Create and delete vhosts Apr 6, 2018
headers = HTTP::Headers{"Content-Type" => "application/json"}

begin
if name = options["remove"]?
resp = HTTP::Client.delete "#{options["host"]}/api/#{entity}", headers, name.to_s
resp = HTTP::Client.delete "#{options["host"]}/api/#{entity}", headers, { name: name.to_s, vhost: options["vhost"]? }.to_json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't vhost and name be in the path? DELETE /api/vhost/exchange/my-exchange ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I think we should use kemal for route parsing etc. then. I'll save that improvement for another branch

save_server_definitions
end

private def load_server_definitions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does server_ have to be in the name? when we are in the Server class?

def delete(context)
case context.request.path
when "/api/policies"
body = JSON.parse(context.request.body.not_nil!)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure that body is never nil here?

data.each do |k, v|
case k
when "vhosts"
v.each { |vhost| create_vhost(vhost["name"].as_s, false) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in create_vhost we call save_server_definitions that overwrites the file we're currently reading from. You probably want to pass a flag to create_vhost, or not call save_defintions from create_vhost at all, instead always do it outside the create/delete-vhost methods

@@ -17,14 +17,16 @@ module AvalancheMQ
@wfile : MessageFile
@log : Logger

def initialize(@name : String, @server_data_dir : String, server_log : Logger)
def initialize(@name : String, @server_data_dir : String, server_log : Logger, clean = false)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could clean be ambiguous? is truncate or wipe better? or instead of passing a flag, should we only allow deleting it as a mean of wiping it?

@carlhoerberg carlhoerberg merged commit b1c8be5 into master Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants