Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra Work #2

Open
CMCDragonkai opened this issue Mar 2, 2014 · 0 comments
Open

Extra Work #2

CMCDragonkai opened this issue Mar 2, 2014 · 0 comments

Comments

@CMCDragonkai
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant