Guide to RESTful Webservices

My company is currently switching our core application from Python to Julia. The application is used as a RESTful web service by other internal web services which are exposed to our clients.

Everything goes smooth so far but what I am missing is a request validation. In Python we used Marshmallow to serialize the requests and more importantly to validate them. In my opinion this validation made our code base much cleaner as we had a clear separation between actual logic and preparation.

So I was looking for a similar package in Julia and could not find anything. JSON3.jl is great for serializing but does not provide a validation. Does anyone of you know a suitable package? Otherwise I was thinking about starting an opensource project for that.

The other thing is that I was missing a summary in how to get a web service running in Julia. There are several tutorials that describe parts of it like how to set up a RESTful API Server with HTTP.jl, use Revise for developing etc. Other things I did not find, for example how to use PackeCompier.js with Docker so you can build containers with Sysimages and make them ready almost immediately if you need to scale up fast.

I guess this would be useful for a lot of companies or other users that want to switch to Julia as we are surely not alone with these “problems”. Does anyone know a nice blog or a book or anything that covers this? Otherwise I could start writing such a guide if there’s interest.

6 Likes

JSON3 already has some pretty powerful validation built in, since it can read JSON directly to a struct: Home · JSON3.jl

This means the types encountered while parsing JSON are necessarily validated. If you need to validate the values further, I suppose that could be done in the constructor of the struct.

1 Like

Yes, I’m talking about further validation like minimum/maximum values, default values, etc. But honestly I did not spend too much time yet on that topic so maybe JSON3 + validating in the constructor will do the trick. I am a bit hesitant because I feel like too much validation in the constructor might get a bit messy, but I’ll give it a try. Otherwise I’ll think of an extension of JSON3.

There is JSONSchema.jl but I never tried it

1 Like

Thanks, I’ll have a look at it!

I found the microservices tutorial by @quinnj (the author of JSON3) very helpful myself.

5 Likes

That’s a very nice tutorial! I had something similar in mind, but in text form.

2 Likes