Documentation ¶
Overview ¶
Package util provides various utilities, including config.
Index ¶
- Variables
- func AuthOwner(r *http.Request) (owner, token string, ok bool)
- func ErrorHTTP(w http.ResponseWriter, code int)
- func LoadConfigFile(filename string) error
- func MatchGQLParam(field, param string, q GraphQLRequest) (string, error)
- func NewGHv4Client(ctx context.Context, token string) *githubv4.Client
- type GHv4ClientMaker
- type GraphQLRequest
Constants ¶
This section is empty.
Variables ¶
var Config struct { Server struct { Host string Port uint16 TLS struct { Crt string Key string } } GitHub struct { Owners []string Replace []struct { Patt uRegexp Repl string } } }
Config represents the global configuration of the server. TODO: refactor out global variable?
Functions ¶
func AuthOwner ¶
AuthOwner checks a request for Basic Auth credentials that both exist and are allowed to use this server.
func ErrorHTTP ¶
func ErrorHTTP(w http.ResponseWriter, code int)
ErrorHTTP replies to a request with an error code and the associated standard error text.
func LoadConfigFile ¶
LoadConfigFile merges the given TOML configuration file into the global configuration.
func MatchGQLParam ¶
func MatchGQLParam(field, param string, q GraphQLRequest) (string, error)
MatchGQLParam extracts a param included in a GraphQL query string.
Types ¶
type GHv4ClientMaker ¶
GHv4ClientMaker describes how to create GitHub GraphQL API clients.
func NewGHv4ClientMaker ¶
func NewGHv4ClientMaker(serve http.HandlerFunc) GHv4ClientMaker
NewGHv4ClientMaker provides tests a way to mock the GitHub GraphQL API. TODO: validate token
type GraphQLRequest ¶
GraphQLRequest is used for unmarshalled GraphQL JSON request bodies.