handlers

package
v0.0.0-...-39e0c7e Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: GPL-3.0 Imports: 52 Imported by: 0

Documentation

Overview

Package handlers contains the HTTP server along with the requests and routes. All HTTP related functions are in this package.

More info on: https://github.com/statping/statping

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(r *http.Request, obj interface{}) error

func ExecuteResponse

func ExecuteResponse(w http.ResponseWriter, r *http.Request, file string, data interface{}, redirect interface{})

ExecuteResponse will render a HTTP response for the front end user

func Gzip

func Gzip(handler http.Handler) http.Handler

func IsAdmin

func IsAdmin(r *http.Request) bool

IsAdmin returns true if the user session is an administrator

func IsFullAuthenticated

func IsFullAuthenticated(r *http.Request) bool

IsFullAuthenticated returns true if the HTTP request is authenticated. You can set the environment variable GO_ENV=test to bypass the admin authenticate to the dashboard features.

func IsReadAuthenticated

func IsReadAuthenticated(r *http.Request) bool

IsReadAuthenticated will allow Read Only authentication for some routes

func IsUser

func IsUser(r *http.Request) bool

IsUser returns true if the user is registered

func MaintenanceRouter

func MaintenanceRouter() *mux.Router

Router returns all of the routes used in Statping. Server will use static assets if the 'assets' directory is found in the root directory.

func Router

func Router() *mux.Router

Router returns all of the routes used in Statping. Server will use static assets if the 'assets' directory is found in the root directory.

func RunHTTPServer

func RunHTTPServer()

RunHTTPServer will start a HTTP server on a specific IP and port

func SafeJson

func SafeJson(val reflect.Value, scope string) map[string]interface{}

TODO: make a better way to parse

func ScopeName

func ScopeName(r *http.Request) string

ScopeName will show private JSON fields in the API. It will return "admin" if request has valid admin authentication.

func StopHTTPServer

func StopHTTPServer(err error)

Types

type ExportData

type ExportData struct {
	Config          *configs.DbConfig            `json:"config,omitempty"`
	Core            *core.Core                   `json:"core"`
	Services        []services.Service           `json:"services"`
	Messages        []*messages.Message          `json:"messages"`
	Incidents       []*incidents.Incident        `json:"incidents"`
	IncidentUpdates []*incidents.IncidentUpdate  `json:"incident_updates"`
	Checkins        []*checkins.Checkin          `json:"checkins"`
	Users           []*users.User                `json:"users"`
	Groups          []*groups.Group              `json:"groups"`
	Notifiers       []notifications.Notification `json:"notifiers"`
}

func ExportSettings

func ExportSettings() (*ExportData, error)

func (*ExportData) JSON

func (e *ExportData) JSON() []byte

type JwtClaim

type JwtClaim struct {
	Username string `json:"username"`
	Admin    bool   `json:"admin"`
	Scopes   string `json:"scopes"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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