kemal-session does not persist data

https://github.com/kemalcr/kemal-session Analyse what is happening with your session cookie. In my case, the session cookie was reset everytime I went to login. I realized, that my idea of cleaning up the old session as a first statement after successful login, before setting up the new session is not a good idea. I suspect, that the…

Weiterlesen

Using modules in crystal

As your application grows, you would like to move from one big .cr file to separating your code into smaller files. You can use require from your main .cr file to add code from other files: require “./tools/*” This statement will add code from the tools directory, relative to your main .cr file. This will…

Weiterlesen

Route & Redirect with envoy

An example envoy.yaml showing how to route & redirect. There are different options, see here https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/route/route.proto#route-redirectaction This envoy.yaml routes /taxgod and /taxgod/ (the second could probably be omitted because the first one should also match it, I think) to a new port and a different protocol. /picockpit is simply redirected to / and then finally…

Weiterlesen

Envoy routing and rewriting snippet

It is possible to rewrite URLs with Envoy for the backend. Please note that the HTML output needs to have the proper routes! (That is why I am not going to investigate further in this direction). REF: https://www.envoyproxy.io/docs/envoy/latest/api-v2/api/v2/route/route.proto#route-route  Also note that the string is going to be rendered literally for direct_response –> body –> inline_string,…

Weiterlesen

envoy force SSL example envoy.yaml

static_resources:   listeners:   – address:       socket_address:         address: 0.0.0.0         port_value: 80     filter_chains:     – filters:       – name: envoy.http_connection_manager         config:           codec_type: auto           stat_prefix: ingress_http           route_config:             virtual_hosts:             – name: backend               domains: [“*”]               routes:               – match: { prefix: “/” }                 redirect:                   path_redirect: “/”                   https_redirect: true           http_filters:           – name: envoy.router             config: {}   – address:       socket_address:         address: 0.0.0.0         port_value: 443     filter_chains:     – tls_context:        …

Weiterlesen

envoy.yaml example for http and https rewriting

This is an early example of working with envoy. I find the documentation to be difficult to get into, therefore I will try to track my progress by infrequent blog posts on the matter. The following envoy.yaml works for me for http and https rewriting to google: static_resources:   listeners:   – address:       socket_address:         address: 0.0.0.0         port_value:…

Weiterlesen

Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError) Crystal

While trying to parse an Amazon pay file, I stumbled across this particular problem: Exception: Unexpected quote at 1:2 (CSV::MalformedCSVError) The reason: Amazon Pay encodes it’s files in UTF-8 with BOM. The BOM is an optional (in UTF-8 files) marker. You can see it with the tool xxd for instance xxd apolish_amazon_2018DecMonthlyTransaction.csv | less The…

Weiterlesen