Last active
December 1, 2024 20:18
-
-
Save dbreunig/2a571e31c2d31e188aee91b3ec3c18d7 to your computer and use it in GitHub Desktop.
How to respond to a DuckDB request – identified by the fairly rare user agent 'cpp-httplib' – in a Rails controller, returning a database file in the `public` folder.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HomeController < ApplicationController | |
def index | |
# Intercept DuckDB requests | |
if request.user_agent =~ /cpp-httplib/ | |
send_file(Rails.root.join('public', 'public_lists.db'), | |
type: 'application/octet-stream', | |
disposition: 'attachment') | |
return | |
end | |
# Handle non-DuckDB requests... | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment