sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

[host] add domainShow

This commit is contained in:
Martin Geno 2016-10-22 21:20:21 +02:00
parent c0970754cb
commit 1c07e35024
3 changed files with 33 additions and 0 deletions

View File

@ -31,6 +31,7 @@ func BindAPI(db *gorm.DB, router *goji.Mux, prefix string) {
router.HandleFuncC(pat.Get(prefix+"/profil"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(profil)))) router.HandleFuncC(pat.Get(prefix+"/profil"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(profil))))
router.HandleFuncC(pat.Get(prefix+"/domain"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainList)))) router.HandleFuncC(pat.Get(prefix+"/domain"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainList))))
router.HandleFuncC(pat.Get(prefix+"/domain/:domainid"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainShow))))
router.HandleFuncC(pat.Post(prefix+"/domain"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainAdd)))) router.HandleFuncC(pat.Post(prefix+"/domain"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainAdd))))
router.HandleFuncC(pat.Patch(prefix+"/domain/:domainid"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainEdit)))) router.HandleFuncC(pat.Patch(prefix+"/domain/:domainid"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainEdit))))
router.HandleFuncC(pat.Delete(prefix+"/domain/:domainid"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainDelete)))) router.HandleFuncC(pat.Delete(prefix+"/domain/:domainid"), libapi.SessionHandler(system.LoginHandler(ProfilHandler(domainDelete))))

View File

@ -52,6 +52,19 @@ func domainList(ctx context.Context, w http.ResponseWriter, r *http.Request) (re
return return
} }
func domainShow(ctx context.Context, w http.ResponseWriter, r *http.Request) (returndata interface{}, returnerr *libapi.ErrorResult) {
returndata = false
logger := log.GetLog(r, "domainlist")
domain, returnerr := getDomain(ctx, w)
if returnerr != nil {
logger.Info("not found")
return
}
logger.Info("done")
returndata = domain
return
}
func domainAdd(ctx context.Context, w http.ResponseWriter, r *http.Request) (returndata interface{}, returnerr *libapi.ErrorResult) { func domainAdd(ctx context.Context, w http.ResponseWriter, r *http.Request) (returndata interface{}, returnerr *libapi.ErrorResult) {
profil := ctx.Value("profil").(*Profil) profil := ctx.Value("profil").(*Profil)
returndata = false returndata = false

View File

@ -120,6 +120,25 @@ func TestAPIDomain(t *testing.T) {
assertion.Equal(w.StatusCode, http.StatusBadRequest) assertion.Equal(w.StatusCode, http.StatusBadRequest)
assertion.Equal(result.Data, false) assertion.Equal(result.Data, false)
/*
* TEST domainShow
*/
session.Clean()
result, w = session.JSONRequest("GET", "/host/domain/"+strconv.Itoa(domain), nil)
assertion.Equal(w.StatusCode, http.StatusUnauthorized)
assertion.Equal(result.Data, false)
loginTest(session, assertion)
result, w = session.JSONRequest("GET", "/host/domain/"+strconv.Itoa(-1), nil)
assertion.Equal(w.StatusCode, http.StatusNotFound)
assertion.Equal(result.Data, false)
result, w = session.JSONRequest("GET", "/host/domain/"+strconv.Itoa(domain), nil)
assertion.Equal(w.StatusCode, http.StatusOK)
assertion.NotEqual(result.Data, false)
/* /*
* TEST domainDelete * TEST domainDelete
*/ */