Speedrun kickoff with RequestHeaderParser, first taste of Elixir

Yasser Hussain
Chingu FCC Speedrun
2 min readApr 17, 2017

Recently fcc-speedrun (designed by P1xt and promoted by Chance Taken) started.

I decided to participate in this speedrun with a completely new stack, something I had never seen before. From many choices available I picked Elixir language and Phoenix framework.

Which tutorials did I follow?

Now to be honest I did not find Elixir totally new because I had tried (and given up) learning Haskell before. (Some concepts are similar like Guards, Pattern Matching, etc.)

But it still seemed confusing. What really helped was Stephen Grider’s excellent course on Udemy and Introducing Elixir book.

How did I implement it?

Setting up Elixir and Phoenix was straightforward. What was tricky was finding a package which would parse the UserAgent for me. I looked at a number of such elixir packages (just google “user agent parser elixir”, you’ll find packages aplenty). But I had a hard time integrating them in my app. Weird errors were thrown on the screen. Finally, one library did work - UA Parser.

Integrating it in my project was simple. I just followed the instructions on their README page and I was good to go.

Other parts like actually retrieving headers from requests and so on were not very difficult. Some amount of googling showed me how to implement those.

For those of you who want to know more details about this app, as always heroku stored the actual IP address of the user in the

x-forwarded-for header.

You can see code here.

Deploying to remote server

The difficult part was deploying it to a remote server. Phoenix docs say you have to add phoenix buildpacks to deploy it and I had no idea what buildpacks were because up until now I had only deployed node applications to heroku and they did not require adding any buildpacks. Deploying node app to heroku is extremely simple.

Also up until now I had not used heroku CLI. So it was a new thing for me.

But after a little trial and error I was able to deploy the app to heroku. You can see the end result here.

If you too want to deploy an Elixir app to heroku, I wrote a small tutorial for doing so.

What do I think of Elixir language?

I haven’t made an opinion on the language yet. I have just begin to scratch its surface. But hopefully in my subsequent posts I will be in a position to share my thoughts on it.

Thanks for reading!

--

--