util

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package util provides various utilities, including config.

Index

Constants

This section is empty.

Variables

View Source
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

func AuthOwner(r *http.Request) (owner, token string, ok bool)

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

func LoadConfigFile(filename string) error

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.

func NewGHv4Client

func NewGHv4Client(ctx context.Context, token string) *githubv4.Client

NewGHv4Client constructs a production GitHub GraphQL API client.

Types

type GHv4ClientMaker

type GHv4ClientMaker func(ctx context.Context, token string) *githubv4.Client

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

type GraphQLRequest struct {
	Query     string
	Variables map[string]interface{}
}

GraphQLRequest is used for unmarshalled GraphQL JSON request bodies.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL