Commit Graph

11 Commits

Author SHA1 Message Date
pancho horrillo
1e63f3c104 feat: Control API uses automatic cross-pinning mTLS (Closes #119)
. kapow server generates on startup a pair of certificates
that will use to secure communications to its control server.
It will communicate the server and client certificates as well
as the client private key to the init programs it launches,
via environment variables.

. kapow server now understands a new flag --control-reachable-addr
which accepts either a IP address or a DNS name, that can be used
to ensure that the generated server certificate will be appropiate
in case the control server must be accessed from something other
than localhost.

Co-authored-by: Roberto Abdelkader Martínez Pérez <robertomartinezp@gmail.com>
2021-03-12 17:24:17 +01:00
pancho horrillo
75b0908b16 Rename GetReasonFromBody() to simply Reason()
See ¹ for the customary idiomatic way of naming getters in Go.

¹: https://golang.org/doc/effective_go.html#Getters
2019-11-20 05:04:10 +01:00
pancho horrillo
81c677c3be internal/http/request.go: replace GetReason() with GetReasonFromBody()
Update tests to inject the required JSON error body with reason.
2019-11-19 21:17:49 +01:00
pancho horrillo
2d5743af84 Add blank line between legal header and package declaration
Otherwise, the legal header is rendered as package documentation.
2019-11-13 18:18:44 +01:00
Héctor Hurtado
723e4787b3 Added legal header to all Go source files 2019-10-23 13:35:01 +02:00
pancho horrillo
0cab49f082 Simplify handling of http.Client response
As per the doc¹:

  If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close.
  ...
  On error, any Response can be ignored. A non-nil Response with a non-nil error
  only occurs when CheckRedirect fails, and even then the returned Response.Body
  is already closed.

It is thus safe to defer res.Body.Close() as soon as err has been determined to
be nil.

Also, I've dispensed with the separate variable client, since it is not used
later.

¹: https://godoc.org/net/http#Client.Do
2019-10-08 05:42:33 +02:00
Roberto Abdelkader Martínez Pérez
4224984e1b Add spacing to comments 2019-10-04 14:18:42 +02:00
Roberto Abdelkader Martínez Pérez
9f7fc8ce62 Allow user specify Content-Type header 2019-10-03 20:55:11 +02:00
pancho horrillo
306889c958 Add TODO on closing the connection of the http.Client
Co-authored-by: Héctor Hurtado <hector.hurtado@bbva.com>
2019-10-03 16:52:55 +02:00
Roberto Abdelkader Martínez Pérez
b1c2db057c Shorthand functions request with common HTTP methods 2019-10-03 15:06:26 +02:00
Roberto Abdelkader Martínez Pérez
681ee3cba8 http becomes an internal package 2019-10-03 14:12:14 +02:00