Exemplo n.º 1
0
// FindStatementHead handles request of get meta information
func (c *Controller) FindStatementHead(params martini.Params,
	languages acceptlang.AcceptLanguages, w http.ResponseWriter, req *http.Request) (int, string) {

	// check version of xAPI
	xAPIVersion := req.Header.Get("X-Experience-API-Version")
	if !validator.IsValidXAPIVersion(xAPIVersion) {
		return NewBadRequestErr("Invalid or empty xAPI version given in X-Experience-API-Version").Response()
	}

	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("X-Experience-API-Version", "1.0.2")
	w.Header().Set("Content-Type", "application/json") // BUG: this header is wrong when attachments given

	return http.StatusOK, ""
}
Exemplo n.º 2
0
// FindStatement handles request of search statement
func (c *Controller) FindStatement(params martini.Params,
	languages acceptlang.AcceptLanguages, w http.ResponseWriter, req *http.Request) (int, string) {
	user, app := params["user"], params["app"]

	// check version of xAPI
	xAPIVersion := req.Header.Get("X-Experience-API-Version")
	if !validator.IsValidXAPIVersion(xAPIVersion) {
		return NewBadRequestErr("Invalid or empty xAPI version given in X-Experience-API-Version").Response()
	}

	urlParams := req.URL.Query()
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("X-Experience-API-Version", "1.0.2")

	// find single statement if statementId or voidedStatementId is specified
	if len(urlParams.Get("statementId")) > 0 || len(urlParams.Get("voidedStatementId")) > 0 {
		return c.findSingleStatement(xAPIVersion, user, app, urlParams, w)
	}

	// otherwise find multiple statments
	return c.findMultipleStatements(xAPIVersion, user, app, languages, urlParams, w)
}