Пример #1
0
func (p *LoginAccountRequestHandler) ContentTypesProvided(req wm.Request, cxt wm.Context) ([]wm.MediaTypeHandler, wm.Request, wm.Context, int, error) {
	genFunc := func() (jsonhelper.JSONObject, time.Time, string, int, http.Header) {
		lac := cxt.(LoginAccountContext)
		jsonObj := lac.Result()
		headers := apiutil.AddNoCacheHeaders(nil)
		return jsonObj, time.Time{}, "", http.StatusOK, headers
	}
	return []wm.MediaTypeHandler{apiutil.NewJSONMediaTypeHandlerWithGenerator(genFunc, time.Time{}, "")}, req, cxt, 0, nil
}
Пример #2
0
func (p *ViewContactRequestHandler) ContentTypesProvided(req wm.Request, cxt wm.Context) ([]wm.MediaTypeHandler, wm.Request, wm.Context, int, error) {
	genFunc := func() (jsonhelper.JSONObject, time.Time, string, int, http.Header) {
		vcc := cxt.(ViewContactContext)
		jsonObj := vcc.Result()
		headers := apiutil.AddNoCacheHeaders(nil)
		return jsonObj, vcc.LastModified(), vcc.ETag(), http.StatusOK, headers
	}
	return []wm.MediaTypeHandler{apiutil.NewJSONMediaTypeHandlerWithGenerator(genFunc, time.Time{}, "")}, req, cxt, 0, nil
}
Пример #3
0
func (p *LogoutAccountRequestHandler) ProcessPost(req wm.Request, cxt wm.Context) (wm.Request, wm.Context, int, http.Header, io.WriterTo, error) {
	var err error
	var code int
	var headers http.Header
	var writerTo io.WriterTo
	lac := cxt.(LogoutAccountContext)
	if lac.AccessKey() != nil {
		_, err = p.authDS.DeleteAccessKey(lac.AccessKey().Id)
	}
	httpHeaders := apiutil.AddNoCacheHeaders(nil)
	if err != nil {
		code, headers, writerTo = apiutil.OutputErrorMessage("Unable to process logout request", nil, http.StatusInternalServerError, httpHeaders)
	} else {
		code, headers, writerTo = apiutil.OutputJSONObject(nil, time.Time{}, "", http.StatusOK, httpHeaders)
	}
	return req, cxt, code, headers, writerTo, nil
}