elixir

2 Articles

How I split Plug.SSL to control SSL redirection

This post was originally published on the BetterDoc Dev-Blog.

Recently I set out to configure a service at work to run behind a reverse proxy with TLS termination.

With Phoenix being the great framework it is, I assumed this would be a breeze. But it turned out that reality had different plans for me.

In this post I’ll tell you a story on all the different bits of documentation I rummaged through, the things I learned from reading the source code of Plug.SSL, the solution I arrived at, and the proposal I submitted to plug.

How I deal with behaviours and boilerplate

This post was originally published on the BetterDoc Dev-Blog.

For a while now I’ve been a big fan of using the Elixir library mox for creating test mocks. When using mox you define behaviours as basis for your mocks. You can think of behaviours as interfaces in object oriented languages such as Java: a set of function signatures that a module has to implement.

While this approach is great - check out this blog post on the why - it tends to require a bit of boilerplate code. In this post we are going to explore how I use behaviours for mocking, the reasoning behind it, and how I reduce the necessary boilerplate to an absolute minimum by using metaprogramming.