Commits vergleichen
Keine gemeinsamen Commits. „main“ und „v0.5.4“ haben vollständig unterschiedliche Historien.
5 geänderte Dateien mit 48 neuen und 77 gelöschten Zeilen
32
go.mod
32
go.mod
|
@ -6,35 +6,37 @@ require (
|
|||
github.com/crewjam/saml v0.4.8
|
||||
github.com/flosch/pongo2/v6 v6.0.0
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
github.com/google/uuid v1.3.0
|
||||
github.com/jackc/pgx-gofrs-uuid v0.0.0-20220402203838-5fdaf7ddb8a2
|
||||
github.com/jackc/pgx/v5 v5.1.1
|
||||
github.com/jackc/tern/v2 v2.0.0-beta.3
|
||||
github.com/rs/xid v1.4.0
|
||||
github.com/rs/zerolog v1.28.0
|
||||
go.sebtobie.de/generic v1.0.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
||||
github.com/jackc/puddle/v2 v2.0.0 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Masterminds/goutils v1.1.1 // indirect
|
||||
github.com/Masterminds/semver/v3 v3.1.1 // indirect
|
||||
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
|
||||
github.com/beevik/etree v1.1.0 // indirect
|
||||
github.com/crewjam/httperr v0.2.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-ap/jsonld v0.0.0-20221030091449-f2a191312c73
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.1 // indirect
|
||||
github.com/goccy/go-json v0.9.11 // indirect
|
||||
github.com/gofrs/uuid v4.2.0+incompatible // indirect
|
||||
github.com/huandu/xstrings v1.3.2 // indirect
|
||||
github.com/imdario/mergo v0.3.13 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/puddle/v2 v2.1.2 // indirect
|
||||
github.com/jonboulle/clockwork v0.2.2 // indirect
|
||||
github.com/jackc/pgx/v5 v5.0.4
|
||||
github.com/jackc/tern/v2 v2.0.0-beta.3
|
||||
github.com/jonboulle/clockwork v0.3.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/mattermost/xml-roundtrip-validator v0.1.0 // indirect
|
||||
|
@ -44,18 +46,16 @@ require (
|
|||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/russellhaering/goxmldsig v1.1.1 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
golang.org/x/crypto v0.3.0 // indirect
|
||||
golang.org/x/crypto v0.2.0 // indirect
|
||||
golang.org/x/net v0.2.0 // indirect
|
||||
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 // indirect
|
||||
golang.org/x/sys v0.2.0 // indirect
|
||||
golang.org/x/text v0.4.0 // indirect
|
||||
google.golang.org/protobuf v1.28.1 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
||||
|
||||
retract [v0.0.0,v0.5.1] // bugs in the whole module that result in crashes
|
||||
|
|
39
go.sum
39
go.sum
|
@ -35,8 +35,6 @@ github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4
|
|||
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
|
||||
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
|
||||
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs=
|
||||
github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
|
@ -57,16 +55,15 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
|
|||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgx-gofrs-uuid v0.0.0-20220402203838-5fdaf7ddb8a2 h1:6qEGnCP4zC+VNPCcb3aHpK4vB51mdE0yyjreAEfjI9c=
|
||||
github.com/jackc/pgx-gofrs-uuid v0.0.0-20220402203838-5fdaf7ddb8a2/go.mod h1:qNQYZ2L+Xpfoj0yU0Moom/Hlbre7mQLS3b006rVArMs=
|
||||
github.com/jackc/pgx/v5 v5.1.1 h1:pZD79K1SYv8wc2HmCQA6VdmRQi7/OtCfv9bM3WAXUYA=
|
||||
github.com/jackc/pgx/v5 v5.1.1/go.mod h1:Ptn7zmohNsWEsdxRawMzk3gaKma2obW+NWTnKa0S4nk=
|
||||
github.com/jackc/puddle/v2 v2.1.2 h1:0f7vaaXINONKTsxYDn4otOAiJanX/BMeAtY//BXqzlg=
|
||||
github.com/jackc/puddle/v2 v2.1.2/go.mod h1:2lpufsF5mRHO6SuZkm0fNYxM6SWHfvyFj62KwNzgels=
|
||||
github.com/jackc/pgx/v5 v5.0.4 h1:r5O6y84qHX/z/HZV40JBdx2obsHz7/uRj5b+CcYEdeY=
|
||||
github.com/jackc/pgx/v5 v5.0.4/go.mod h1:U0ynklHtgg43fue9Ly30w3OCSTDPlXjig9ghrNGaguQ=
|
||||
github.com/jackc/puddle/v2 v2.0.0 h1:Kwk/AlLigcnZsDssc3Zun1dk1tAtQNPaBBxBHWn0Mjc=
|
||||
github.com/jackc/puddle/v2 v2.0.0/go.mod h1:itE7ZJY8xnoo0JqJEpSMprN0f+NQkMCuEV/N9j8h0oc=
|
||||
github.com/jackc/tern/v2 v2.0.0-beta.3 h1:eLC0C8KgIHVkcm7fJvrG4B1gTjRO1xkGN1g9gQBoh3k=
|
||||
github.com/jackc/tern/v2 v2.0.0-beta.3/go.mod h1:JC+qkR3EMEgATsTKdYojLBizn2gl4jWQmwqbUxYbA8U=
|
||||
github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ=
|
||||
github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
|
||||
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
|
@ -98,8 +95,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
|
||||
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
|
@ -123,7 +120,6 @@ github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
|||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
|
@ -131,29 +127,26 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
|||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
go.sebtobie.de/generic v1.0.1 h1:N7q6nu5y9+QowBUj49qQgcDxYOxMy+ZIzFhQntclCxQ=
|
||||
go.sebtobie.de/generic v1.0.1/go.mod h1:3AAmr4JfoP2PD7VzRJBAjn+ZiRgaLCYKSOf3wn0nNCM=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20200414173820-0848c9571904/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.0.0-20220128200615-198e4374d7ed/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.3.0 h1:a06MkbcxBrEFc0w0QIZWXrH/9cCX6KJyWbBOIwAn+7A=
|
||||
golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE=
|
||||
golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.1.0 h1:hZ/3BUoy5aId7sCpA/Tc5lt8DkFgdVS2onTpJsZ/fl0=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
|
||||
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
||||
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 h1:ZrnxWX62AgTKOSagEqxvb3ffipvEDX2pl7E1TdqLqIc=
|
||||
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
|
@ -163,6 +156,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
|
13
http.go
13
http.go
|
@ -188,12 +188,11 @@ func (s *Server) Use(m ...gin.HandlerFunc) {
|
|||
}
|
||||
|
||||
// Stop Shuts the Server down
|
||||
func (server *Server) Stop(ctx context.Context) {
|
||||
log.Info().Err(server.http.Shutdown(ctx)).Msg("Server Shut down.")
|
||||
for _, s := range server.sites {
|
||||
func (s *Server) Stop(ctx context.Context) {
|
||||
log.Info().Err(s.http.Shutdown(ctx)).Msg("Server Shut down.")
|
||||
for _, s := range s.sites {
|
||||
if ts, ok := s.(TeardownSite); ok {
|
||||
ts.Teardown()
|
||||
server.routines.Done()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,7 +238,7 @@ func unequal[T comparable](i T) func(t T) bool {
|
|||
// 3. Middleware.Sites
|
||||
// 4. Site.Setup
|
||||
func (s *Server) Setup() {
|
||||
log.Info().Msg("Preparing server for start")
|
||||
log.Info().Msg("Perparing server for start")
|
||||
var (
|
||||
router *gin.Engine
|
||||
found bool
|
||||
|
@ -305,10 +304,6 @@ func (s *Server) Setup() {
|
|||
log.Error().Err(err).Msgf("Failed to setup site with config %s", cfg)
|
||||
}
|
||||
}
|
||||
if _, ok := site.(TeardownSite); ok {
|
||||
log.Trace().Msg("Added teardownsite to the sg")
|
||||
s.routines.Add(1)
|
||||
}
|
||||
}
|
||||
for _, m := range s.advmiddleware {
|
||||
if psm, ok := m.(middleware.PostSetupMiddleware); ok {
|
||||
|
|
|
@ -3,7 +3,6 @@ package db
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"sync"
|
||||
|
@ -14,8 +13,6 @@ import (
|
|||
"github.com/jackc/tern/v2/migrate"
|
||||
"github.com/rs/zerolog/log"
|
||||
"go.sebtobie.de/httpserver/middleware"
|
||||
|
||||
uuid "github.com/jackc/pgx-gofrs-uuid"
|
||||
)
|
||||
|
||||
// ContextKey is the key that is used in a gin.Context to get the Middleware
|
||||
|
@ -28,17 +25,6 @@ var _ ConnGet = NewMiddleware().GetConn
|
|||
var _ middleware.Middleware = &Middleware{}
|
||||
var _ middleware.PostSetupMiddleware = &Middleware{}
|
||||
|
||||
// GetConnection is an simple helper function that returns an connection to the db
|
||||
func GetConnection(c *gin.Context, db string) (*pgxpool.Conn, error) {
|
||||
if co, ok := c.Get(ContextKey); ok {
|
||||
if cg, ok := co.(ConnGet); ok {
|
||||
return cg(db), nil
|
||||
}
|
||||
return nil, fmt.Errorf("Failed to convert the method. %T != ConnGet", co)
|
||||
}
|
||||
return nil, errors.New("No db.Middleware set up. ")
|
||||
}
|
||||
|
||||
// Middleware return a handler that sets the db into the context of every request.
|
||||
// uri is an url in the form dbtype:connectargs
|
||||
type Middleware struct {
|
||||
|
@ -63,14 +49,14 @@ func (m *Middleware) AddDB(name, uri string) (err error) {
|
|||
var (
|
||||
db *pgxpool.Pool
|
||||
)
|
||||
db, err = pgxpool.New(context.TODO(), uri)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Could not open the database")
|
||||
return err
|
||||
}
|
||||
db.Config().AfterConnect = func(_ context.Context, c *pgx.Conn) error {
|
||||
uuid.Register(c.TypeMap())
|
||||
return nil
|
||||
db, err = pgxpool.New(context.TODO(), uri)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Could not open the database")
|
||||
return err
|
||||
}
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
|
@ -106,7 +92,7 @@ func (m *Middleware) GetConn(name string) *pgxpool.Conn {
|
|||
|
||||
// Gin is the Entrypoint for Gin.
|
||||
func (m *Middleware) Gin(c *gin.Context) {
|
||||
c.Set(ContextKey, ConnGet(m.GetConn))
|
||||
c.Set(ContextKey, m.GetConn)
|
||||
}
|
||||
|
||||
// Setup adds the connections from the configfile into the middleware
|
||||
|
@ -193,7 +179,7 @@ func SetupMigrator(prefix string, connection *pgx.Conn, migrations fs.FS) (mig *
|
|||
mig, err = migrate.NewMigratorEx(
|
||||
context.TODO(),
|
||||
connection,
|
||||
prefix+"version",
|
||||
"version",
|
||||
&migrate.MigratorOptions{
|
||||
DisableTx: false,
|
||||
},
|
||||
|
@ -202,13 +188,12 @@ func SetupMigrator(prefix string, connection *pgx.Conn, migrations fs.FS) (mig *
|
|||
log.Error().Err(err).Msg("Error while creating the migrator")
|
||||
return
|
||||
}
|
||||
mig.OnStart = logmigrations
|
||||
mig.Data["prefix"] = prefix
|
||||
err = mig.LoadMigrations(migrations)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error while loading migrations")
|
||||
return
|
||||
}
|
||||
log.Trace().Interface("migrations", mig.Migrations).Interface("data", mig.Data).Err(err).Send()
|
||||
mig.OnStart = logmigrations
|
||||
mig.Data["prefix"] = prefix
|
||||
return
|
||||
}
|
||||
|
|
|
@ -23,14 +23,10 @@ func LogMiddleware(c *gin.Context) {
|
|||
var entry *zerolog.Event
|
||||
interrupt := recover()
|
||||
if interrupt != nil {
|
||||
entry = log.Error().Int("statuscode", 500)
|
||||
if err, ok := interrupt.(error); ok {
|
||||
entry.Err(err).Stack()
|
||||
} else {
|
||||
entry.Interface("recover", interrupt)
|
||||
}
|
||||
err := interrupt.(error)
|
||||
c.Header("requestid", id.String())
|
||||
c.AbortWithStatus(http.StatusInternalServerError)
|
||||
entry = log.Error().Err(err).Int("statuscode", 500)
|
||||
entry.Stack()
|
||||
} else {
|
||||
statuscode := c.Writer.Status()
|
||||
|
@ -44,7 +40,7 @@ func LogMiddleware(c *gin.Context) {
|
|||
}
|
||||
entry.Int("statuscode", statuscode)
|
||||
}
|
||||
entry.Str("xid", id.String()).Msg("Request")
|
||||
entry.Bytes("xid", id.Bytes()).Msg("Request")
|
||||
}()
|
||||
c.Next()
|
||||
}
|
||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren