Skip to content

Extra Work #2

Open
Open
@CMCDragonkai

Description

@CMCDragonkai

Changing to File Extensions rather than Static File Checking

This replaces the check static files options. Please remove all mentions of it.

Relevant sections of code:

  1. Detector.php Line 31 - 45 https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/src/SnapSearchClientPHP/Detector.php#L31-L45
  2. Detector.php Line 100 - 101 line https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/src/SnapSearchClientPHP/Detector.php#L100-L101
  3. Detector.php Line 181 - 242 https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/src/SnapSearchClientPHP/Detector.php#L181-L242
  4. extensions.json https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/resources/extensions.json
  5. Tests:

Utilise this regex (it has been been modified to work in Ruby):

/
    ^            # Regex begins at the beginning of the string
    (?:          # Begin non-capturing group
        (?!      # Negative lookahead, this presence of such a sequence will fail the regex
        [?#]     # Question mark or hash character
        .*       # Any or more wildcard characters
        \/       # Literal slash
        [^\/?#]+ # {file} - has one or more of any character except forward slash, question mark or hash
        \.       # Literal dot
        [^\/?#]+ # {extension} - has one or more of any character except forward slash, question mark or hash
        )        # This negative lookahead prevents any ? or # that precedes the {file}.{extension} by any characters
        .        # Wildcard
    )*           # Non-capturing group that will capture any number of wildcard that passes the negative lookahead
    \/           # Literal slash
    [^\/?#]+     # {file} - has one or more of any character except forward slash, question mark or hash
    \.           # Literal dot
    ([^\/?#]+)   # {extension} - Subgroup has one or more of any character except forward slash, question mark or hash
/ux

Before Intercept and After Intercept Hooks (Using Procs) in the Interceptor

These should inside the interceptor, allowing people to hook into the before and after interception to allow client side caching.

Relevant Sections of Code:

  1. Interceptor.php Line 54 - 95 https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/src/SnapSearchClientPHP/Interceptor.php#L54-L95
  2. Interceptor.php Line 108 - 123 https://github.com/SnapSearch/SnapSearch-Client-PHP/blob/master/src/SnapSearchClientPHP/Interceptor.php#L108-L123
  3. Tests are all in the Interceptor Test. They might be written in a different way in Ruby. These are the conditions:
    • Before Intercept Needs to Receive the Current Url
    • Before Intercept that returns an array, that array will be the response array from the entire middleware
    • Before intercept that returns anything else, it will not be the response from the entire middleware
    • After intercept should receive the current url and response array
    • Intercept callables that are not callables will not be called
    • Intercept callables can be chained

Rack Flexibility - all options that are in the Detector/Client/Interceptor (after/before intercept hooks) should be available in the config.rb inside the rack folder.

I noticed that the Rack accepts an options hash. This is then put into the config.rb object. Can you make it so that the config.rb object can accept all the options that are available on Detector, Client and Interceptor.

Furthermore, I would like it so that the user can pass a callback such as a proc, that essentially receives the response array from the middleware, and can return an array specifying the status code, headers (key to value) and body response. This would replace this part: https://github.com/SnapSearch/SnapSearch-Client-Ruby/blob/master/lib/rack/snap_search.rb#L56-L82

However if the user does not pass back a body response, then what you have currently already written should be used as a fallback default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions