Sha256: 3a20916b8d52b262a753eb49a5f9b2b0c7edc09ed4fb4324c46ff13980914340

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

module Shogun
  module Server
    def serve
      @rack.use(Rack::Log, @logger)
      @rack.use(Rack::Runtime)
      @rack.use(Rack::Protection::HttpOrigin, origin_whitelist: origin_whitelist)
      @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

    private def origin_whitelist
      self.class.const_get("ORIGIN_WHITELIST")
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
shogun-6.4.2 lib/shogun/server.rb
shogun-6.4.1 lib/shogun/server.rb
shogun-6.4.0 lib/shogun/server.rb
shogun-6.3.0 lib/shogun/server.rb
shogun-6.2.3 lib/shogun/server.rb
shogun-6.2.2 lib/shogun/server.rb
shogun-6.2.1 lib/shogun/server.rb
shogun-6.2.0 lib/shogun/server.rb
shogun-6.1.0 lib/shogun/server.rb
shogun-6.0.0 lib/shogun/server.rb
shogun-4.0.1 lib/shogun/server.rb
shogun-4.0.0 lib/shogun/server.rb
shogun-3.4.0 lib/shogun/server.rb