Moving From Server Side Sessions To Client Side Session Tokens with Servant

Documenting my move from Network.Wai.Session to Web.ClientSession

vados

12 minute read

tl;dr - I moved from server-side stored sessions provided by Network.Wai.Session to client-side signed+encrypted session tokens provided by Wai.ClientSession for my Servant-powered webapp, it’s pretty easy, skim through to see the setup code, /login and /logout code that was required. UPDATE After posting to r/haskell, user u/cocreature pointed out the existence of the servant-auth package – it looks like an awesome solution so also make sure to give that a try before rolling your own.

Static Binaries for Haskell: A Convoluted Approach

A convoluted (but working) path to building binaries for a Haskell app

vados

17 minute read

Static Binaries for a Haskell: A convoluted approach NOTE - this blog post has been updated, thanks to feedback from the reddit community in pointing out ways this should have been done/done better! If you read any part of this with any intent to use it, definitely read the updates at the end! tl;dr - After a bunch of trial and error, I end up building a mostly static binary from a docker container.

Graylog as a hslogger backend in Haskell

Setting up Graylog as a hslogger backend in Haskell

vados

10 minute read

tl;dr - It’s pretty easy to use Graylog as a System.Logger backend, check out the code at the end, also if you’re interested in just regular crash-level logging with Servant, there’s some code you might like at the bottom too. On a recent contract I was introduced to Graylog – it’s a pretty awesome log aggregation tool, with a great rontend and I was drawn to the simplicity of use.

End To End Testing With Hspec (Almost)

Setting up E2E testing with HSpec and PhantomJS.

vados

10 minute read

tl;dr While the setup works, the most mature haskell library for dealing with webdrivers that I could find wasn’t able to keep up with the changes in Selenium Webdriver :(. Skim through the post to check out the relevant code snippets and tech that made it all (almost) work. If you’re not familiar with Haskell, check it out. This isn’t an introductory type post so it might not be for you, but the language is amazing.

Adding A Merge Patch Content Type To Servant

How to add a content type for HTTP spec compliant merge-patching in Servant

vados

6 minute read

*tl;dr See the code at the end Very often when developing a web application I run into the age-old problem of how to do partial updates. Doing the “U” (Update) in CRUD is actually a little more complicated than just accepting PUTs at some endpoint if you dont’ want to replace the object as a whole. I’ve often worked around this while maintaining somewhere-near spec complicance by just using the catch-all that is POST, and taking whatever object represented the update and doing whatever needed to be done.

Case Study: Building A URL Bouncer

Building a URL bouncer for a servant-powered web application

vados

19 minute read

tl;dr - Building a simple URL bouncer with Servant isn’t that hard, and the usual warm fuzzies you get from well-typed functions, interfaces, and code still apply If you’re not familiar with Haskell or Servant, the former is a programming language that focuses on pure functional concepts and the latter is one of the most interesting/popular frameworks for it that specializes in exposing your API as a type itself. A brief taste of both of these things is below:

vados

9 minute read

tl/dr; I tried to expand the cookie-based auth I implemented in servant and failed. While I’ll probably try again some other day, for now I just resorted to writing functions to get the functions for a user and do checking directly in my handlers Here’s the tale of how I tried to add Role checking (based on my application’s defined Role type) to my servant app, and ran into a few issues and things I didn’t understand and ultimately failed.

Adding Cookie Based Auth To Servant

Some commentary on the experience adding Cookie based authentication for a Servant API

vados

10 minute read

One of the applications I’ve been working on exclusively lately is a surprisingly large Job Board application. Not the most exciting concept, I know, but it’s quickly becoming the culmination of some of the best development (and consequently “engineering”) work that I’ve ever done. The codebase is growing huge – 11,000+ lines counting both front and backend code, and while I haven’t gone on any large refactoring sprees, most of the code does not make me feel bad.

vados

5 minute read

Getting started with servant, part 2 tldr; Use enter to inject database information, monads and monad transformers rear their ugly heads but not for long. Multi-part blog post alert This is a multi-part blog-post! Part 1 - Getting Started with servant Part 2 - Getting Started with servant, Part 2 What are the ways to pass database information into an application using servant? From what I can tell, there are 3 main approaches to getting the database management object (whatever that is) into the app:

Getting started with servant (Part 1)

Adventures in functional programming and simple web API servers

vados

12 minute read

Getting started with Servant tldr; Haskell cool, Servant is awesome, and is a really interesting way to represent APIs in a way blessed by Haskell’s enormously powerful type system. Starting with it can be kind of difficult, but it’s a good kind of mind-bending. Multi-part blog post alert This is a multi-part blog-post! Part 1 - Getting Started with servant Part 2 - Getting Started with servant, Part 2 Background Recently I’ve been working on a project called The Start, which is meant to be a job board targeting some niches job markets in Tokyo/Japan.