Today I learned about NATS, microservice API and security

Actual security, as in identity, is still a 3rd party thing, aka you still need a OIDC IDP (or oauth2 in the broadest sense or similar).
All NATS security does is validate that the credentials you pass the a client are valid and enforce limits, if configured.

The microservice API was necessary, since simple request/reply structure was lacking errors, logging and statistics.
micro.Request actually has a convenience req.RespondJSON() function.

A small example?

So right now I have, ent for the database stuff and nats over websocket for the service requests.
But I’m having big issues with NATS Jetstream.
The ws client is blocking, despite callbacks and async.

The micro package also has a long way to go.
Regular HTTP has middleware, micro doesn’t seem to have it, maybe I’m missing something. OTOH I could just pass the request to a next function, but it’s not very elegant.

Replace text recursively

I’m in the process of moving from my gogs instance on git.icod.de to my gitea instance on code.icod.de
In this process I’m migrating countless packages manually. It’s quite a lot of work.

Often I need to replace “git.icod.de’ with ‘code.icod.de’

To do this on a Linux machine I use the following 1-liner:

In this example I’m replacing git.icod.de/dalu/blogs with code.icod.de/dalu/blogs. Since sed uses regexp search I have to escape the . and /. I could’ve used ~ as delimiters. If I had the 1-liner would look like this: