servertools

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: LGPL-3.0 Imports: 21 Imported by: 14

README



Festivals Server Tools

The festivals server tools repository contains server functions shared between most server components of the FestivalsApp.


DevelopmentDeploymentEngageLicensing


Between the server components of the FestivalsApp are some shared tasks they need to complete, like sending a heartbeat to the festivals-gateway, updating the server binary from github, sending responses to clients and more. To reduce duplicate code and simplify refactoring those functions are exposed via this tools repository. Some implementations are strongly coupled with ohter server components like ... TBC

Development

TBA

Deployment

TBA

Engage

I welcome every contribution, whether it is a pull request or a fixed typo. The best place to discuss questions and suggestions regarding the festivals-server-tools is the issues section. More general information and a good starting point if you want to get involved is the festival-documentation repository.

The following channels are available for discussions, feedback, and support requests:

Type Channel
General Discussion
Other Requests

Licensing

Copyright (c) 2023 Simon Gaus.

Licensed under the GNU Lesser General Public License v3.0 (the "License"); you may not use this file except in compliance with the License.

You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.html.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the LICENSE for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FileExists

func FileExists(filename string) bool

Checks if a file exists and isn't a directory. see: https://golangcode.com/check-if-a-file-exists/

func HeartbeatClient

func HeartbeatClient(clientCert string, clientKey string) (*http.Client, error)

func InitializeGlobalLogger

func InitializeGlobalLogger(logfile string, console bool)

func IsEntitled

func IsEntitled(keys []string, endpoint func(http.ResponseWriter, *http.Request)) http.HandlerFunc

func LatestVersion added in v0.0.2

func LatestVersion(organisation string, repository string) (string, error)

func Middleware

func Middleware(traceLogger *zerolog.Logger) func(next http.Handler) http.Handler

func NewRollingFile

func NewRollingFile(file string) (io.Writer, error)

func RespondCode

func RespondCode(w http.ResponseWriter, code int)

func RespondError

func RespondError(w http.ResponseWriter, code int, message string)

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, payload interface{})

func RespondString

func RespondString(w http.ResponseWriter, code int, message string)

func RunUpdate added in v0.0.2

func RunUpdate(currentVersion string, organisation string, repository string, updateScriptPath string) (string, error)

func SendHeartbeat

func SendHeartbeat(client *http.Client, endpoint string, serviceKey string, beat *Heartbeat) error

func TraceLogger

func TraceLogger(logfile string) *zerolog.Logger

func UnauthorizedResponse added in v0.0.3

func UnauthorizedResponse(w http.ResponseWriter)

Types

type Heartbeat

type Heartbeat struct {
	Service   string `json:"service"`
	Host      string `json:"host"`
	Port      int    `json:"port"`
	Available bool   `json:"available"`
}

Jump to

Keyboard shortcuts

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