handlers

package
v0.90.74 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: GPL-3.0 Imports: 51 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 added in v0.90.11

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 added in v0.90.11

func Gzip(handler http.Handler) http.Handler

func IsAdmin added in v0.80.3

func IsAdmin(r *http.Request) bool

IsAdmin returns true if the user session is an administrator

func IsFullAuthenticated added in v0.80.2

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 added in v0.80.2

func IsReadAuthenticated(r *http.Request) bool

IsReadAuthenticated will allow Read Only authentication for some routes

func IsUser added in v0.80.3

func IsUser(r *http.Request) bool

IsUser returns true if the user is registered

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() error

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

func SafeJson added in v0.90.11

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

TODO: make a better way to parse

func ScopeName added in v0.90.11

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 added in v0.90.47

func StopHTTPServer(err error)

Types

type ExportData added in v0.90.11

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 added in v0.90.11

func ExportSettings() (*ExportData, error)

func (*ExportData) JSON added in v0.90.67

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

type JwtClaim added in v0.90.11

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