Sha256: 121ea95ae2251d6b5737962dee547cbb0cfb834f5c8684b31ce7439c292b8d42

Contents?: true

Size: 932 Bytes

Versions: 11

Compression:

Stored size: 932 Bytes

Contents

module Dyndnsd
  module Responder
    class RestStyle
      def response_for_error(state)
        # general http errors
        return [405, {"Content-Type" => "text/plain"}, ["Method Not Allowed"]] if state == :method_forbidden
        return [404, {"Content-Type" => "text/plain"}, ["Not Found"]] if state == :not_found
        # specific errors
        return [422, {"Content-Type" => "text/plain"}, ["Hostname missing"]] if state == :hostname_missing
        return [403, {"Content-Type" => "text/plain"}, ["Forbidden"]] if state == :host_forbidden
        return [422, {"Content-Type" => "text/plain"}, ["Hostname malformed"]] if state == :hostname_malformed
      end
      
      def response_for_changes(states, ip)
        body = states.map { |state| state == :good ? "Changed to #{ip}" : "No change needed for #{ip}" }.join("\n")
        return [200, {"Content-Type" => "text/plain"}, [body]]
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
dyndnsd-1.5.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.4.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.3.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.2.2 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.2.1 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.2.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.1.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-1.0.0 lib/dyndnsd/responder/rest_style.rb
dyndnsd-0.0.4 lib/dyndnsd/responder/rest_style.rb
dyndnsd-0.0.3 lib/dyndnsd/responder/rest_style.rb
dyndnsd-0.0.2 lib/dyndnsd/responder/rest_style.rb