Rename to Service

Add ModelService interface to merge all Services
This commit is contained in:
Jan Bader 2016-12-27 00:47:10 +01:00
parent 5b9b2e02a0
commit e525fdc928
3 changed files with 6 additions and 6 deletions

View File

@ -26,7 +26,7 @@ func main() {
tv := &jwt.TokenVerifier{}
h := &http.Handler{
UserService: us,
Service: us,
TokenVerifier: tv,
CredentialsVerifier: bv,
}

View File

@ -5,7 +5,7 @@ import "git.javil.eu/jacob1123/budgeteer"
type TemplateData struct {
token jwt.Token
budgetService budgeteer.BudgetService
budgetService budgeteer.ModelService
}
func (d *TemplateData) GetToken() jwt.Token {

View File

@ -11,7 +11,7 @@ import (
// Handler handles incoming requests
type Handler struct {
UserService budgeteer.UserService
Service budgeteer.ModelService
TokenVerifier budgeteer.TokenVerifier
CredentialsVerifier budgeteer.CredentialVerifier
}
@ -120,7 +120,7 @@ func (h *Handler) loginPost(c *gin.Context) {
username, _ := c.GetPostForm("username")
password, _ := c.GetPostForm("password")
user, err := h.UserService.UserByUsername(username)
user, err := h.Service.UserByUsername(username)
if err != nil {
c.AbortWithError(http.StatusUnauthorized, err)
return
@ -149,7 +149,7 @@ func (h *Handler) registerPost(c *gin.Context) {
password, _ := c.GetPostForm("password")
name, _ := c.GetPostForm("name")
user, err := h.UserService.UserByUsername(email)
user, err := h.Service.UserByUsername(email)
if err == nil {
c.AbortWithStatus(http.StatusUnauthorized)
return
@ -166,7 +166,7 @@ func (h *Handler) registerPost(c *gin.Context) {
Password: hash,
Email: email,
}
err = h.UserService.CreateUser(user)
err = h.Service.CreateUser(user)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
}