web

package
v3.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderSabactlUser is the HTTP header name to tell which user run sabactl.
	HeaderSabactlUser = "X-Sabakan-User"
)

Variables

View Source
var (
	APIErrBadRequest     = APIError{http.StatusBadRequest, "invalid request", nil}
	APIErrForbidden      = APIError{http.StatusForbidden, "forbidden", nil}
	APIErrNotFound       = APIError{http.StatusNotFound, "requested resource is not found", nil}
	APIErrBadMethod      = APIError{http.StatusMethodNotAllowed, "method not allowed", nil}
	APIErrConflict       = APIError{http.StatusConflict, "conflicted", nil}
	APIErrLengthRequired = APIError{http.StatusLengthRequired, "content-length is required", nil}
	APIErrTooLargeAsset  = APIError{http.StatusRequestEntityTooLarge, "too large asset", nil}
)

Common API errors

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status  int
	Message string
	Err     error
}

APIError is to define REST API errors.

func BadRequest

func BadRequest(reason string) APIError

BadRequest creates an APIError that describes what was bad in the request.

func InternalServerError

func InternalServerError(e error) APIError

InternalServerError creates an APIError.

func (APIError) Error

func (e APIError) Error() string

Error implements error interface.

type Server

type Server struct {
	Model          sabakan.Model
	MyURL          *url.URL
	MyURLHTTPS     *url.URL
	IPXEFirmware   string
	CryptSetup     string
	AllowedRemotes []*net.IPNet
	Counter        *metrics.APICounter

	TLSServer bool
	// contains filtered or unexported fields
}

Server is the sabakan server.

func NewServer

func NewServer(model sabakan.Model, ipxePath, cryptsetupPath string,
	advertiseURL, advertiseURLHTTPS *url.URL, allowedIPs []*net.IPNet, enablePlayground bool, counter *metrics.APICounter, tlsServer bool) *Server

NewServer constructs Server instance

func (Server) ServeHTTP

func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.ServeHTTP

Jump to

Keyboard shortcuts

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