http

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ShutdownTimeout is the time given for outstanding requests to finish
	// before shutdown.
	ShutdownTimeout = 1 * time.Second
)

Variables

This section is empty.

Functions

func CreateObject

func CreateObject(w http.ResponseWriter, r *http.Request, opts interface{}, creator func(opts interface{}) (interface{}, error))

CreateObject is a helper for creating an object, unmarshalling and marshalling the request and response from/to JSON-API.

func DecodeAndSanitize

func DecodeAndSanitize(dst Sanitizable, src map[string][]string) error

Decode query string into a struct and sanitize the struct values

func ErrNotFound

func ErrNotFound(w http.ResponseWriter, opts ...ErrOption)

func ErrServerFailure

func ErrServerFailure(w http.ResponseWriter, err error)

func ErrUnprocessable

func ErrUnprocessable(w http.ResponseWriter, err error)

func GetObject

func GetObject(w http.ResponseWriter, r *http.Request, getter func() (interface{}, error))

GetObject is a helper for getting an object and marshalling back to JSON-API

func ListObjects

func ListObjects(w http.ResponseWriter, r *http.Request, lister func() (interface{}, error))

ListObjects is a helper for listing objects and marshalling back to JSON-API

func MarshalPayload

func MarshalPayload(w io.Writer, models interface{}, include ...string) (err error)

func NewRouter

func NewRouter(server *Server) *negroni.Negroni

NewRouter constructs a negroni-wrapped HTTP router

func UpdateObject

func UpdateObject(w http.ResponseWriter, r *http.Request, opts interface{}, updater func(opts interface{}) (interface{}, error))

UpdateObject is a helper for updating an object, unmarshalling and marshalling the request and response from/to JSON-API.

Types

type ErrOption

type ErrOption func(*jsonapi.ErrorObject)

func WithDetail

func WithDetail(detail string) ErrOption

type Sanitizable

type Sanitizable interface {
	Sanitize()
}

Sanitizable implementations can sanitize their values

type Server

type Server struct {
	SSL               bool
	CertFile, KeyFile string

	// Listening Address in the form <ip>:<port>
	Addr string

	OrganizationService ots.OrganizationService
	WorkspaceService    ots.WorkspaceService
	StateVersionService ots.StateVersionService
	// contains filtered or unexported fields
}

The HTTP/S server

func NewServer

func NewServer() *Server

NewServer is the contructor for Server

func (*Server) Close

func (s *Server) Close() error

Close gracefully shuts down the server.

func (*Server) CreateOrganization

func (h *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) CreateStateVersion

func (h *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) CreateWorkspace

func (h *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) CurrentStateVersion

func (h *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteOrganization

func (h *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteWorkspace

func (h *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) DeleteWorkspaceByID

func (h *Server) DeleteWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) DownloadStateVersion

func (h *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) GetEntitlements

func (h *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)

func (*Server) GetOrganization

func (h *Server) GetOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) GetStateVersion

func (h *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)

func (*Server) GetWorkspace

func (h *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) GetWorkspaceByID

func (h *Server) GetWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) ListOrganizations

func (h *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)

func (*Server) ListStateVersions

func (h *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)

func (*Server) ListWorkspaces

func (h *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)

func (*Server) LockWorkspace

func (h *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) Open

func (s *Server) Open() (err error)

Open validates the server options and begins listening on the bind address.

func (*Server) Port

func (s *Server) Port() int

Port returns the TCP port for the running server. This is useful in tests where we allocate a random port by using ":0".

func (*Server) UnlockWorkspace

func (h *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateOrganization

func (h *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateWorkspace

func (h *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)

func (*Server) UpdateWorkspaceByID

func (h *Server) UpdateWorkspaceByID(w http.ResponseWriter, r *http.Request)

func (*Server) Wait

func (s *Server) Wait(ctx context.Context) error

Wait blocks until server stops listening or context is cancelled.

func (*Server) WellKnown

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

type WellKnown

type WellKnown struct {
	ModulesV1  string `json:"modules.v1"`
	MotdV1     string `json:"motd.v1"`
	StateV2    string `json:"state.v2"`
	TfeV2      string `json:"tfe.v2"`
	TfeV21     string `json:"tfe.v2.1"`
	TfeV22     string `json:"tfe.v2.2"`
	VersionsV1 string `json:"versions.v1"`
}

Jump to

Keyboard shortcuts

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