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
Conversation
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 |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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
src/avalanchemq/server.cr
Outdated
save_server_definitions | ||
end | ||
|
||
private def load_server_definitions |
There was a problem hiding this comment.
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?
src/avalanchemq/http_server.cr
Outdated
def delete(context) | ||
case context.request.path | ||
when "/api/policies" | ||
body = JSON.parse(context.request.body.not_nil!) |
There was a problem hiding this comment.
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?
src/avalanchemq/server.cr
Outdated
data.each do |k, v| | ||
case k | ||
when "vhosts" | ||
v.each { |vhost| create_vhost(vhost["name"].as_s, false) } |
There was a problem hiding this comment.
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
src/avalanchemq/vhost.cr
Outdated
@@ -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) |
There was a problem hiding this comment.
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?
1cbe478
to
2904ff5
Compare
No description provided.