Initial commit
This commit is contained in:
		
							parent
							
								
									feff3a3400
								
							
						
					
					
						commit
						16c5e37a8c
					
				|  | @ -0,0 +1,11 @@ | |||
| module scm.yoorie.de/go-lib/micro | ||||
| 
 | ||||
| go 1.16 | ||||
| 
 | ||||
| require ( | ||||
| 	github.com/go-chi/chi v1.5.4 | ||||
| 	github.com/go-chi/cors v1.2.0 | ||||
| 	github.com/go-chi/render v1.0.1 | ||||
| 	scm.yoorie.de/go-lib/certs v0.0.1 | ||||
| 	scm.yoorie.de/go-lib/gelf v0.0.1 | ||||
| ) | ||||
|  | @ -0,0 +1,134 @@ | |||
| github.com/aphistic/sweet v0.3.0 h1:xZTMfCoMsjWubPNxOBODluBC4qfGP0CdRJ88jon46XE= | ||||
| github.com/aphistic/sweet v0.3.0/go.mod h1:fWDlIh/isSE9n6EPsRmC0det+whmX6dJid3stzu0Xys= | ||||
| github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= | ||||
| github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= | ||||
| github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= | ||||
| github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||||
| github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= | ||||
| github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= | ||||
| github.com/go-chi/chi v1.5.4 h1:QHdzF2szwjqVV4wmByUnTcsbIg7UGaQ0tPF2t5GcAIs= | ||||
| github.com/go-chi/chi v1.5.4/go.mod h1:uaf8YgoFazUOkPBG7fxPftUylNumIev9awIWOENIuEg= | ||||
| github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE= | ||||
| github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= | ||||
| github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8= | ||||
| github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns= | ||||
| github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= | ||||
| github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= | ||||
| github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= | ||||
| github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= | ||||
| github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= | ||||
| github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= | ||||
| github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= | ||||
| github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= | ||||
| github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= | ||||
| github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= | ||||
| github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= | ||||
| github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= | ||||
| github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= | ||||
| github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= | ||||
| github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= | ||||
| github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= | ||||
| github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= | ||||
| github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= | ||||
| github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= | ||||
| github.com/mattn/go-colorable v0.1.1 h1:G1f5SKeVxmagw/IyvzvtZE4Gybcc4Tr1tf7I8z0XgOg= | ||||
| github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= | ||||
| github.com/mattn/go-isatty v0.0.5 h1:tHXDdz1cpzGaovsTB+TVB8q90WEokoVmfMqoVcrLUgw= | ||||
| github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= | ||||
| github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4= | ||||
| github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE= | ||||
| github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= | ||||
| github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= | ||||
| github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= | ||||
| github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= | ||||
| github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= | ||||
| github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= | ||||
| github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= | ||||
| github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= | ||||
| github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= | ||||
| github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= | ||||
| github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= | ||||
| github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= | ||||
| github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= | ||||
| github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||||
| github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||||
| github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= | ||||
| github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= | ||||
| github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||||
| github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||||
| github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= | ||||
| golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= | ||||
| golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= | ||||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= | ||||
| golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||||
| golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= | ||||
| golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= | ||||
| golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= | ||||
| golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= | ||||
| golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= | ||||
| golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= | ||||
| golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= | ||||
| golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= | ||||
| golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= | ||||
| golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= | ||||
| golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= | ||||
| golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/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-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= | ||||
| golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= | ||||
| golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= | ||||
| golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= | ||||
| golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= | ||||
| golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= | ||||
| golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= | ||||
| golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= | ||||
| golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= | ||||
| golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= | ||||
| golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= | ||||
| golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= | ||||
| golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | ||||
| google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= | ||||
| google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= | ||||
| google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= | ||||
| google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= | ||||
| google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= | ||||
| google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= | ||||
| google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= | ||||
| google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= | ||||
| gopkg.in/aphistic/golf.v0 v0.0.0-20180712155816-02c07f170c5a h1:34vqlRjuZiE9c8eHsuZ9nn+GbcimFpvGUEmW+vyfhG8= | ||||
| gopkg.in/aphistic/golf.v0 v0.0.0-20180712155816-02c07f170c5a/go.mod h1:fvTxI2ZW4gO1d+4q4VCKOo+ANBs4gPN3IW00MlCumKc= | ||||
| gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||||
| gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= | ||||
| gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= | ||||
| gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | ||||
| gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= | ||||
| gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= | ||||
| gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= | ||||
| gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= | ||||
| scm.yoorie.de/go-lib/certs v0.0.1 h1:4FwWaIjtMQbhpr75kVD7Ymvz5fwpeM5kt1jrjrIHFsg= | ||||
| scm.yoorie.de/go-lib/certs v0.0.1/go.mod h1:CYe8HvRaply1NRTQ9YnllvdijoZwNR4yXGhrN1L9BhM= | ||||
| scm.yoorie.de/go-lib/gelf v0.0.1 h1:VcCUihF1zyOiDfPg2NWLyaBoJjundua624RBAPJx/vU= | ||||
| scm.yoorie.de/go-lib/gelf v0.0.1/go.mod h1:p4HaHQX4mcgclzYB8nomFHvYLLdz64yr7MYlV5+Oz/I= | ||||
|  | @ -0,0 +1,105 @@ | |||
| package web | ||||
| 
 | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/go-chi/chi" | ||||
| 	log "scm.yoorie.de/go-lib/gelf" | ||||
| ) | ||||
| 
 | ||||
| /* | ||||
| healthChecker Class | ||||
| */ | ||||
| type healthChecker struct { | ||||
| 	message     string | ||||
| 	healthy     bool | ||||
| 	lastChecked time.Time | ||||
| 	period      int | ||||
| 	ticker      *time.Ticker | ||||
| 	done        chan bool | ||||
| 	//This is the healtchcheck you will have to provide.
 | ||||
| 	checkFunc func() (bool, string) | ||||
| } | ||||
| 
 | ||||
| func newHealthChecker(checkFunction func() (bool, string)) *healthChecker { | ||||
| 	hc := &healthChecker{} | ||||
| 	hc.checkFunc = checkFunction | ||||
| 	return hc | ||||
| } | ||||
| 
 | ||||
| func (h *healthChecker) start(checkPeriodInSeconds int) { | ||||
| 	h.period = checkPeriodInSeconds | ||||
| 	h.message = "service starting" | ||||
| 	h.healthy = false | ||||
| 	h.doCheck() | ||||
| 	h.ticker = time.NewTicker(time.Second * time.Duration(h.period)) | ||||
| 	h.done = make(chan bool) | ||||
| 	go func() { | ||||
| 		for { | ||||
| 			select { | ||||
| 			case <-h.done: | ||||
| 				return | ||||
| 			case <-h.ticker.C: | ||||
| 				h.doCheck() | ||||
| 			} | ||||
| 		} | ||||
| 	}() | ||||
| } | ||||
| 
 | ||||
| func (h *healthChecker) stop() { | ||||
| 	h.ticker.Stop() | ||||
| 	h.done <- true | ||||
| 	log.Debug("Health checker stopped.") | ||||
| } | ||||
| 
 | ||||
| //internal function to process the health check
 | ||||
| func (h *healthChecker) doCheck() { | ||||
| 	var msg string | ||||
| 	h.healthy, msg = h.checkFunc() | ||||
| 	if !h.healthy { | ||||
| 		h.message = msg | ||||
| 	} else { | ||||
| 		h.message = "" | ||||
| 	} | ||||
| 	h.lastChecked = time.Now() | ||||
| } | ||||
| 
 | ||||
| // Routes add routes for liveness and readyness probes
 | ||||
| func (h *healthChecker) Routes() *chi.Mux { | ||||
| 	router := chi.NewRouter() | ||||
| 	router.Get("/healthz", h.healthyEndpoint) | ||||
| 	router.Get("/readyz", h.readinessEndpoint) | ||||
| 	return router | ||||
| } | ||||
| 
 | ||||
| /* | ||||
| GetHealthyEndpoint is this service healthy | ||||
| */ | ||||
| func (h *healthChecker) healthyEndpoint(response http.ResponseWriter, req *http.Request) { | ||||
| 	t := time.Now() | ||||
| 	if t.Sub(h.lastChecked) > (time.Second * time.Duration(2*h.period)) { | ||||
| 		h.healthy = false | ||||
| 		h.message = "Healthcheck not running" | ||||
| 	} | ||||
| 	response.Header().Add("Content-Type", "application/json") | ||||
| 	if h.healthy { | ||||
| 		response.WriteHeader(http.StatusOK) | ||||
| 		message := fmt.Sprintf(`{ "message": "service up and running", "lastCheck": "%s" }`, h.lastChecked.String()) | ||||
| 		response.Write([]byte(message)) | ||||
| 	} else { | ||||
| 		response.WriteHeader(http.StatusServiceUnavailable) | ||||
| 		message := fmt.Sprintf(`{ "message": "service is unavailable: %s", "lastCheck": "%s" }`, h.message, h.lastChecked.String()) | ||||
| 		response.Write([]byte(message)) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| /* | ||||
| GetReadinessEndpoint is this service ready for taking requests | ||||
| */ | ||||
| func (h *healthChecker) readinessEndpoint(response http.ResponseWriter, req *http.Request) { | ||||
| 	response.Header().Add("Content-Type", "application/json") | ||||
| 	response.WriteHeader(http.StatusOK) | ||||
| 	response.Write([]byte(`{ "message": "service started" }`)) | ||||
| } | ||||
|  | @ -0,0 +1,275 @@ | |||
| package web | ||||
| 
 | ||||
| import ( | ||||
| 	"compress/flate" | ||||
| 	"context" | ||||
| 	"crypto/tls" | ||||
| 	"fmt" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"os/signal" | ||||
| 	"strconv" | ||||
| 	"time" | ||||
| 
 | ||||
| 	"github.com/go-chi/chi" | ||||
| 	"github.com/go-chi/chi/middleware" | ||||
| 	"github.com/go-chi/cors" | ||||
| 	"github.com/go-chi/render" | ||||
| 	"scm.yoorie.de/go-lib/certs" | ||||
| 	log "scm.yoorie.de/go-lib/gelf" | ||||
| ) | ||||
| 
 | ||||
| type WebServerConfiguration struct { | ||||
| 	Host                        string                         `yaml:"host"` | ||||
| 	Port                        int                            `yaml:"port"` | ||||
| 	SslPort                     int                            `yaml:"sslport"` | ||||
| 	SslCert                     string                         `yaml:"sslcert"` | ||||
| 	SslKey                      string                         `yaml:"sslkey"` | ||||
| 	HealthCheckPeriod           int                            `yaml:"healthcheckperiod"` | ||||
| 	CertificateGenerationParams TLSCertificateGenerationParams `yaml:"tlsgenerationparams"` | ||||
| } | ||||
| 
 | ||||
| type TLSCertificateGenerationParams struct { | ||||
| 	Organization string        `default:"acme.com" yaml:"organization"` | ||||
| 	Host         string        `default:"localhost" yaml:"host"` | ||||
| 	ValidForDays time.Duration `default:"3650" yaml:"validfor"` // Value in days
 | ||||
| } | ||||
| 
 | ||||
| type WebServer struct { | ||||
| 	serviceConfig *WebServerConfiguration | ||||
| 	sslsrv        *http.Server | ||||
| 	srv           *http.Server | ||||
| 	ssl           bool | ||||
| 	healthChecker *healthChecker | ||||
| 	router        *chi.Mux | ||||
| 	healthRouter  *chi.Mux | ||||
| 	mounts        map[string]http.Handler | ||||
| 	HealthCheck   func() (bool, string) | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) healthRoutes() *chi.Mux { | ||||
| 	compressor := middleware.NewCompressor(flate.DefaultCompression) | ||||
| 	router := chi.NewRouter() | ||||
| 	router.Use( | ||||
| 		render.SetContentType(render.ContentTypeJSON), | ||||
| 		compressor.Handler, | ||||
| 		middleware.Recoverer, | ||||
| 	) | ||||
| 	router.Mount("/", server.healthChecker.Routes()) | ||||
| 	return router | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) Mount(pattern string, handler http.Handler) { | ||||
| 	server.mounts[pattern] = handler | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) routes() *chi.Mux { | ||||
| 	compressor := middleware.NewCompressor(flate.DefaultCompression) | ||||
| 	router := chi.NewRouter() | ||||
| 	router.Use( | ||||
| 		compressor.Handler, | ||||
| 		middleware.Recoverer, | ||||
| 		cors.Handler(cors.Options{ | ||||
| 			AllowedOrigins:   []string{"https://*", "http://*"}, | ||||
| 			AllowedMethods:   []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}, | ||||
| 			AllowedHeaders:   []string{"Accept", "Authorization", "Content-Type", "X-CSRF-Token"}, | ||||
| 			ExposedHeaders:   []string{"Link"}, | ||||
| 			AllowCredentials: false, | ||||
| 			MaxAge:           300, // Maximum value not ignored by any of major browsers
 | ||||
| 		}), | ||||
| 	) | ||||
| 	router.Mount("/health", server.healthRoutes()) | ||||
| 	// Custom routes
 | ||||
| 	for pattern, handler := range server.mounts { | ||||
| 		router.Mount(pattern, handler) | ||||
| 	} | ||||
| 	return router | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) getTLSConfig() (*tls.Config, error) { | ||||
| 	cert := server.serviceConfig.SslCert | ||||
| 	key := server.serviceConfig.SslKey | ||||
| 	if cert != "" && key != "" { | ||||
| 		log.Infof("Loading SSL certificate %s %s", cert, key) | ||||
| 		cer, err := tls.LoadX509KeyPair(cert, key) | ||||
| 		if err != nil { | ||||
| 			return nil, fmt.Errorf("Cannot load SSL certificat: %v", err) | ||||
| 		} | ||||
| 		return &tls.Config{Certificates: []tls.Certificate{cer}}, nil | ||||
| 	} | ||||
| 	log.Info("Generating SSL certificate") | ||||
| 
 | ||||
| 	params := server.serviceConfig.CertificateGenerationParams | ||||
| 
 | ||||
| 	gc := certs.GenerateCertificate{ | ||||
| 		Organization: params.Organization, | ||||
| 		Host:         params.Host, | ||||
| 		ValidFor:     params.ValidForDays * 24 * time.Hour, | ||||
| 		IsCA:         false, | ||||
| 		EcdsaCurve:   "P256", | ||||
| 		Ed25519Key:   true, | ||||
| 	} | ||||
| 	return gc.GenerateTLSConfig() | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) DebugRoutes(routerName string, router *chi.Mux) { | ||||
| 	walkFunc := func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { | ||||
| 		log.Infof("%s %s", method, route) | ||||
| 		return nil | ||||
| 	} | ||||
| 	log.Infof("Routes of scope %s \n", routerName) | ||||
| 	if err := chi.Walk(router, walkFunc); err != nil { | ||||
| 		log.Alertf("Logging err: %s", err.Error()) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // BuildHostAddress Builds a host address from configuration
 | ||||
| func (c *WebServerConfiguration) BuildHostAddress(ssl bool) string { | ||||
| 	var address string | ||||
| 	if "" == c.Host { | ||||
| 		address += "0.0.0.0" | ||||
| 	} else { | ||||
| 		address += c.Host | ||||
| 	} | ||||
| 	address += ":" | ||||
| 	if ssl { | ||||
| 		address += strconv.Itoa(c.SslPort) | ||||
| 	} else { | ||||
| 		address += strconv.Itoa(c.Port) | ||||
| 	} | ||||
| 	return address | ||||
| } | ||||
| 
 | ||||
| func (c *WebServerConfiguration) GetBindings() string { | ||||
| 
 | ||||
| 	bindingStrings := "" | ||||
| 	if c.SslPort > 0 { | ||||
| 		bindingStrings += "https://" + c.BuildHostAddress(true) + "," | ||||
| 	} | ||||
| 	bindingStrings += "http://" + c.BuildHostAddress(false) | ||||
| 	return bindingStrings | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) performHealthCheck() (bool, string) { | ||||
| 	if server.HealthCheck != nil { | ||||
| 		return server.HealthCheck() | ||||
| 	} | ||||
| 	return true, "" | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) Start(config *WebServerConfiguration) error { | ||||
| 	server.serviceConfig = config | ||||
| 	hc := newHealthChecker(server.performHealthCheck) | ||||
| 	hc.start(config.HealthCheckPeriod) | ||||
| 
 | ||||
| 	server.ssl = server.serviceConfig.SslPort > 0 | ||||
| 	if server.ssl { | ||||
| 		log.Debugf("Running in SSL mode") | ||||
| 	} | ||||
| 
 | ||||
| 	server.router = server.routes() | ||||
| 
 | ||||
| 	server.healthRouter = server.healthRoutes() | ||||
| 	server.DebugRoutes("Main", server.router) | ||||
| 	server.DebugRoutes("Health", server.healthRouter) | ||||
| 	if server.ssl { | ||||
| 		err := server.setupSsl() | ||||
| 		if err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} else { | ||||
| 		// own http server for the healthchecks
 | ||||
| 		httpAddress := server.serviceConfig.BuildHostAddress(false) | ||||
| 		server.srv = &http.Server{ | ||||
| 			Addr:         httpAddress, | ||||
| 			WriteTimeout: time.Second * 15, | ||||
| 			ReadTimeout:  time.Second * 15, | ||||
| 			IdleTimeout:  time.Second * 60, | ||||
| 			Handler:      server.router, | ||||
| 		} | ||||
| 		go func() { | ||||
| 			log.Infof("Starting http server on address: %s", server.srv.Addr) | ||||
| 			if err := server.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { | ||||
| 				log.Alertf("error starting server: %s", err.Error()) | ||||
| 			} | ||||
| 		}() | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) setupHttp() error { | ||||
| 	// own http server for the healthchecks
 | ||||
| 	httpAddress := server.serviceConfig.BuildHostAddress(false) | ||||
| 	server.srv = &http.Server{ | ||||
| 		Addr:         httpAddress, | ||||
| 		WriteTimeout: time.Second * 15, | ||||
| 		ReadTimeout:  time.Second * 15, | ||||
| 		IdleTimeout:  time.Second * 60, | ||||
| 		Handler:      server.router, | ||||
| 	} | ||||
| 	go func() { | ||||
| 		log.Infof("Starting http server on address: %s", server.srv.Addr) | ||||
| 		if err := server.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { | ||||
| 			log.Alertf("error starting server: %s", err.Error()) | ||||
| 		} | ||||
| 	}() | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) setupSsl() error { | ||||
| 	tlsConfig, err := server.getTLSConfig() | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	sslAddress := server.serviceConfig.BuildHostAddress(true) | ||||
| 
 | ||||
| 	server.sslsrv = &http.Server{ | ||||
| 		Addr:         sslAddress, | ||||
| 		WriteTimeout: time.Second * 15, | ||||
| 		ReadTimeout:  time.Second * 15, | ||||
| 		IdleTimeout:  time.Second * 60, | ||||
| 		Handler:      server.router, | ||||
| 		TLSConfig:    tlsConfig, | ||||
| 	} | ||||
| 	go func() { | ||||
| 		log.Infof("Starting https server on address: %s", server.sslsrv.Addr) | ||||
| 		if err := server.sslsrv.ListenAndServeTLS("", ""); err != nil && err != http.ErrServerClosed { | ||||
| 			log.Alertf("error starting server: %s", err.Error()) | ||||
| 		} | ||||
| 	}() | ||||
| 	httpAddress := server.serviceConfig.BuildHostAddress(false) | ||||
| 	server.srv = &http.Server{ | ||||
| 		Addr:         httpAddress, | ||||
| 		WriteTimeout: time.Second * 15, | ||||
| 		ReadTimeout:  time.Second * 15, | ||||
| 		IdleTimeout:  time.Second * 60, | ||||
| 		Handler:      server.healthRouter, | ||||
| 	} | ||||
| 	go func() { | ||||
| 		log.Infof("Starting http server on address: %s", server.srv.Addr) | ||||
| 		if err := server.srv.ListenAndServe(); err != nil && err != http.ErrServerClosed { | ||||
| 			log.Alertf("error starting server: %s", err.Error()) | ||||
| 		} | ||||
| 	}() | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) Join() { | ||||
| 	c := make(chan os.Signal, 1) | ||||
| 	signal.Notify(c, os.Interrupt) | ||||
| 	<-c | ||||
| } | ||||
| 
 | ||||
| func (server *WebServer) Stop() { | ||||
| 	server.healthChecker.stop() | ||||
| 	log.Info("Waiting for clients ...") | ||||
| 	ctx, cancel := context.WithTimeout(context.Background(), time.Second*15) | ||||
| 	defer cancel() | ||||
| 
 | ||||
| 	log.Info("Shutting down server ...") | ||||
| 	server.srv.Shutdown(ctx) | ||||
| 	if server.ssl { | ||||
| 		server.sslsrv.Shutdown(ctx) | ||||
| 	} | ||||
| 	log.Info("Server has been shutted down") | ||||
| } | ||||
		Loading…
	
		Reference in New Issue