Documentation ¶
Index ¶
- Variables
- func GetReqID(r *http.Request) string
- func ListenAndServe(addr string, handler http.Handler) error
- func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error
- func RequestIDMiddleware(next http.Handler) http.Handler
- func RespondAccepted(w http.ResponseWriter, v interface{})
- func RespondCreated(w http.ResponseWriter, v interface{})
- func RespondError(w http.ResponseWriter, err error, code int, reqID string)
- func RespondMessage(w http.ResponseWriter, msg string)
- func RespondNotFound(w http.ResponseWriter)
- func RespondOK(w http.ResponseWriter, v interface{})
- func RespondServeFile(w http.ResponseWriter, f *mahi.FileBlob)
- func Serve(handler http.Handler, port int, https bool, sslCertPath, sslKeyPath string) error
- type Error
- type HealthStats
- type LinksData
- type Message
- type MessageData
- type PaginationData
- type RelationshipData
- type RelationshipsData
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
var DefaultClient = http.DefaultClient
Functions ¶
func ListenAndServe ¶
ListenAndServe just copies the http package ListenAndServe function later on I should refactor this to actually create my own server and handlers for now yolo
func ListenAndServeTLS ¶
ListenAndServeTLS just copies the http package ListenAndServe function later on I should refactor this to actually create my own server and handlers for now yolo
func RequestIDMiddleware ¶
RequestIDMiddleware creates a id for each request coming in. It then passes it down via context
func RespondAccepted ¶
func RespondAccepted(w http.ResponseWriter, v interface{})
Accepted encodes a JSON response and sets the status to HTTP Status to 200 OK
func RespondCreated ¶
func RespondCreated(w http.ResponseWriter, v interface{})
RespondCreated encodes a JSON response and sets the status to HTTP Status to 201 CREATED
func RespondError ¶
func RespondError(w http.ResponseWriter, err error, code int, reqID string)
RespondError writes an API error message to the response and logger.
func RespondMessage ¶
func RespondMessage(w http.ResponseWriter, msg string)
func RespondNotFound ¶
func RespondNotFound(w http.ResponseWriter)
NotFound writes an API error message to the response.
func RespondOK ¶
func RespondOK(w http.ResponseWriter, v interface{})
OK encodes a JSON response and sets the status to HTTP Status to 200 OK
func RespondServeFile ¶
func RespondServeFile(w http.ResponseWriter, f *mahi.FileBlob)
Types ¶
type Error ¶
type Error struct { Error string `json:"error,omitempty"` Type string `json:"type"` RequestID string `json:"requestId"` HTTPCode int `json:"httpCode"` }
Error is a generic HTTP response body for errors.
type HealthStats ¶
type HealthStats struct { AllocatedMemory uint64 `json:"allocatedMemory"` TotalAllocatedMemory uint64 `json:"totalAllocatedMemory"` Goroutines int `json:"goroutines"` GCCycles uint32 `json:"completedGCCycles"` NumberOfCPUs int `json:"cpus"` HeapSys uint64 `json:"maxHeapUsage"` HeapAllocated uint64 `json:"heapInUse"` ObjectsInUse uint64 `json:"objectsInUse"` OSMemoryObtained uint64 `json:"OSMemoryObtained"` }
type Message ¶
type Message struct {
Data *MessageData `json:"data"`
}
type MessageData ¶
type MessageData struct {
Message string `json:"message"`
}
type PaginationData ¶
type RelationshipData ¶
type RelationshipsData ¶
type RelationshipsData struct {
HREF string `json:"href"`
}
type Server ¶
type Server struct { ApplicationService mahi.ApplicationService UploadService mahi.UploadService FileServeService mahi.FileServeService UsageService mahi.UsageService FileService mahi.FileService QueryDecoder *schema.Decoder AuthToken string Log zerolog.Logger *mux.Router }
func NewServer ¶
func NewServer(c *ServerConfig) *Server
type ServerConfig ¶
type ServerConfig struct { ApplicationService mahi.ApplicationService UploadService mahi.UploadService FileServeService mahi.FileServeService UsageService mahi.UsageService FileService mahi.FileService QueryDecoder *schema.Decoder AuthToken string Log zerolog.Logger }
Source Files ¶
- application_request.go
- application_response.go
- application_transport.go
- auth_middleware.go
- file_query.go
- file_response.go
- file_serve_query.go
- file_serve_transport.go
- file_transport.go
- health_transport.go
- request_id_middleware.go
- respond.go
- routes.go
- serve.go
- server.go
- upload_request.go
- upload_transport.go
- usage_query.go
- usage_response.go
- usage_transport.go