Sha256: d23ce1808c437e171178dc2d76ec5b4b9103c3824eaba95a1653a43f622ae1e7

Contents?: true

Size: 1.53 KB

Versions: 3

Compression:

Stored size: 1.53 KB

Contents

module Shogun
  module Server
    def serve
      @rack.use(Rack::Log, @logger)
      @rack.use(Rack::Runtime)
      @rack.use(Rack::Protection::RemoteReferrer)
      @rack.use(Rack::Protection::HttpOrigin)
      @rack.use(Rack::Protection::EscapedParams)
      @rack.use(Rack::Protection::XSSHeader)
      @rack.use(Rack::Protection::FrameOptions)
      @rack.use(Rack::Protection::PathTraversal)
      @rack.use(Rack::Protection::IPSpoofing)
      @rack.use(ActiveRecord::ConnectionAdapters::ConnectionManagement)
      @rack.use(ActiveRecord::QueryCache)
      @rack.use(Rack::Chunker)
      @rack.use(Rack::AcceptSetter, accept_types)
      @rack.use(Rack::ContentLengthSetter)
      @rack.use(Rack::AuthenticationBearer, &bearer)
      @rack.use(Rack::BodyDeserializer, deserialization_map)
      @rack.use(Rack::BodySerializer, serialization_map, default_serializer)
      @rack.use(Rack::Cors, &cors)
      @rack.run(Shogun::Dispatch.new(logger: @logger, &endpoints))
    end

    private def endpoints
      self.class.const_get("ENDPOINTS")
    end

    private def deserialization_map
      self.class.const_get("DESERIALIZATION_MAP")
    end

    private def bearer
      self.class.const_get("BEARER")
    end

    private def serialization_map
      self.class.const_get("SERIALIZATION_MAP")
    end

    private def default_serializer
      self.class.const_get("DEFAULT_SERIALIZER")
    end

    private def accept_types
      self.class.const_get("ACCEPT_TYPES")
    end

    private def cors
      self.class.const_get("CORS")
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shogun-3.1.0 lib/shogun/server.rb
shogun-3.0.0 lib/shogun/server.rb
shogun-2.1.1 lib/shogun/server.rb