Sha256: f0d64278791c12d44c878c0c028c28bf6f80fa446982de6fc97a96b7e48b523c

Contents?: true

Size: 621 Bytes

Versions: 89

Compression:

Stored size: 621 Bytes

Contents

module Brief::Server::Handlers
  class Schema
    def self.handle(path_args, briefcase, options)
      request = options.fetch(:request)

      headers = {"Content-Type"=>"application/json"}

      if request.path == "/schema"
        [200, headers, Brief::Model.classes.map(&:to_schema)]
      elsif request.path.match(/^\/schema\/(.+)$/)
        requested = request.path.split("/").last

        if model = Brief::Model.lookup(requested)
          [200, headers, model.to_schema]
        else
          [404, headers, {error: "Can not find model class matching #{ requested }"}]
        end
      end
    end
  end
end

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
brief-1.17.14 lib/brief/server/handlers/schema.rb
brief-1.17.13 lib/brief/server/handlers/schema.rb
brief-1.17.12 lib/brief/server/handlers/schema.rb
brief-1.17.11 lib/brief/server/handlers/schema.rb
brief-1.17.10 lib/brief/server/handlers/schema.rb
brief-1.17.9 lib/brief/server/handlers/schema.rb
brief-1.17.8 lib/brief/server/handlers/schema.rb
brief-1.17.7 lib/brief/server/handlers/schema.rb
brief-1.17.5 lib/brief/server/handlers/schema.rb
brief-1.17.4 lib/brief/server/handlers/schema.rb
brief-1.17.3 lib/brief/server/handlers/schema.rb
brief-1.17.2 lib/brief/server/handlers/schema.rb
brief-1.17.1 lib/brief/server/handlers/schema.rb
brief-1.17.0 lib/brief/server/handlers/schema.rb
brief-1.16.2 lib/brief/server/handlers/schema.rb
brief-1.16.1 lib/brief/server/handlers/schema.rb
brief-1.16.0 lib/brief/server/handlers/schema.rb
brief-1.15.5 lib/brief/server/handlers/schema.rb
brief-1.15.4 lib/brief/server/handlers/schema.rb
brief-1.15.3 lib/brief/server/handlers/schema.rb