dwyl / dwyl/learn-phoenix

How to serve a specific static file (not CSS, JS or images) in `Phoenix`?

Open
#155 1 comment 0 reactions 1 assignee Claimed by @nelsonic View on GitHub
chore discuss enhancement priority-1 question research T25m technical
Dominant language
No language data
Stars
664
Forks
41
PR merge metrics
No merged PRs in 30d

Description

I would like a easy/simple way to serve a static file in a `Phoenix` App
e.g: when you need to verify a domain the registrar requires a `.txt` file.
This can sometimes be done at the DNS level. But other times it needs to be served by the Application.

My particular use case is the following: I want to serve a copy of the `mix.lock` file from the project
so that I can _easily_ see _exactly_ which version of a dependency is running.

In the past we have served an endpoint that displayed the `Git` version of the App
that we could then lookup on `GitHub` to determine _exactly_ which version of the `App` was running for debugging purposes.

e.g: [`router.ex#L104-L106`](https://github.com/healthlocker/healthlocker/blob/becff6feafb3e10ebe061f7056bcc04bf4755c0c/web/router.ex#L104-L106) and [`controllers/github_version_controller.ex`](https://github.com/healthlocker/healthlocker/blob/master/web/controllers/github_version_controller.ex)

Problem is: I don't think the `Git` history is _available_ on `Fly.io` (it wasn't on `Heroku` ...)
So I think the easiest thing is to serve a `static` file. 📁

Very grateful for any insight other people using `Phoenix` have on this. 💭 💬 🙏

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.