Skip to content

Comments

Add binding for application:get_application()#95

Open
ctrlaltmilk wants to merge 1 commit intogleam-lang:mainfrom
ctrlaltmilk:get-application
Open

Add binding for application:get_application()#95
ctrlaltmilk wants to merge 1 commit intogleam-lang:mainfrom
ctrlaltmilk:get-application

Conversation

@ctrlaltmilk
Copy link

This adds a binding to get_application/0 from the Erlang application module, for use mainly with application.priv_directory(). For example, a web server could expose a function to automatically serve static files from the current application's priv directory.

I briefly considered binding to get_application/1, but that would require either separate functions for getting the application from a PID/module name or a new type, and it's much less common to have multiple applications running in Gleam than in Elixir or Erlang.

@lpil
Copy link
Member

lpil commented Feb 20, 2026

Hello! How did you verify this to be working? There's no tests!

@ctrlaltmilk
Copy link
Author

I tested it separately - from what I can see, the tests don't run inside an application so the only test would be

let assert Error(_) = application.get_application()

If you want it, I can add it - not sure if there's any way to spin up an application inside a test so that the success case gets checked.

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

Successfully merging this pull request may close these issues.

2 participants