Documentation
¶
Index ¶
- Constants
- Variables
- func BadRequest(response *restful.Response, err error)
- func Error(response *restful.Response, httpStatus int, responseError error)
- func InternalServerError(response *restful.Response, err error)
- func Ok(response *restful.Response, content interface{})
- func PageNotFound(response *restful.Response, err error)
- func ParseDuration(request *restful.Request, name string) (time.Duration, error)
- func ParseInt(request *restful.Request, name string, fallback int) (value int, err error)
- func ReadCategories(request *restful.Request, defaultCategories []string) []string
- func Text(response *restful.Response, content string)
- type Feedback
- type FeedbackIterator
- type HealthStatus
- type Item
- type ItemIterator
- type RestServer
- func (s *RestServer) AuthFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func (s *RestServer) CreateWebService()
- func (s *RestServer) LogFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func (s *RestServer) MetricsFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func (s *RestServer) SearchDocuments(collection, subset string, categories []string, ...)
- func (s *RestServer) SetLastModified(request *restful.Request, response *restful.Response, key string)
- func (s *RestServer) StartHttpServer(container *restful.Container)
- type Server
- type Success
- type UserIterator
Constants ¶
const ( HealthAPITag = "health" UsersAPITag = "users" ItemsAPITag = "items" FeedbackAPITag = "feedback" RecommendationAPITag = "recommendation" MeasurementsAPITag = "measurements" DetractedAPITag = "deprecated" )
Variables ¶
var ( RestAPIRequestSecondsVec = promauto.NewHistogramVec(prometheus.HistogramOpts{ Namespace: "gorse", Subsystem: "server", Name: "rest_api_request_seconds", }, []string{"api"}) )
Functions ¶
func BadRequest ¶
BadRequest returns a bad request error.
func InternalServerError ¶
InternalServerError returns a internal server error.
func PageNotFound ¶
PageNotFound returns a not found error.
func ParseDuration ¶
ParseDuration parses duration from the query parameter.
func ReadCategories ¶
ReadCategories tries to read categories from the request. If the category is not found, it returns an empty string.
Types ¶
type Feedback ¶
type Feedback struct {
data.FeedbackKey
Value float64
Timestamp string
Comment string
}
Feedback is the data structure for the feedback but stores the timestamp using string.
type FeedbackIterator ¶
FeedbackIterator is the iterator for feedback.
type HealthStatus ¶
type Item ¶
type Item struct {
ItemId string
IsHidden bool
Categories []string
Timestamp string
Labels any
Comment string
}
Item is the data structure for the item but stores the timestamp using string.
type ItemIterator ¶
ItemIterator is the iterator for items.
type RestServer ¶
type RestServer struct {
Config *config.Config
CacheClient cache.Database
DataClient data.Database
HttpHost string
HttpPort int
DisableLog bool
WebService *restful.WebService
HttpServer *http.Server
}
RestServer implements a REST-ful API server.
func (*RestServer) AuthFilter ¶
func (s *RestServer) AuthFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
func (*RestServer) CreateWebService ¶
func (s *RestServer) CreateWebService()
CreateWebService creates web service.
func (*RestServer) LogFilter ¶
func (s *RestServer) LogFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
func (*RestServer) MetricsFilter ¶
func (s *RestServer) MetricsFilter(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
func (*RestServer) SearchDocuments ¶
func (*RestServer) SetLastModified ¶
func (*RestServer) StartHttpServer ¶
func (s *RestServer) StartHttpServer(container *restful.Container)
StartHttpServer starts the REST-ful API server.
type Server ¶
type Server struct {
RestServer
// contains filtered or unexported fields
}
Server manages states of a server node.
func NewServer ¶
func NewServer( masterHost string, masterPort int, serverHost string, serverPort int, cacheFile string, tlsConfig *util.TLSConfig, ) *Server
NewServer creates a server node.
func (*Server) ServerName ¶
type Success ¶
type Success struct {
RowAffected int
}
Success is the returned data structure for data insert operations.