diff options
-rw-r--r-- | charakterin.go | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/charakterin.go b/charakterin.go index 2878f1f..413d698 100644 --- a/charakterin.go +++ b/charakterin.go | |||
@@ -24,6 +24,11 @@ const ( | |||
24 | EmailAlreadyRegistered = "pq: email_already_registered" | 24 | EmailAlreadyRegistered = "pq: email_already_registered" |
25 | ) | 25 | ) |
26 | 26 | ||
27 | // external services | ||
28 | const ( | ||
29 | ANILIST = "Anilist" | ||
30 | ) | ||
31 | |||
27 | // Renderer wird verwendet, um die Routen (bspw. Login-Route) zu rendern. Damit bleibt Charakterin selbst ohne Template. | 32 | // Renderer wird verwendet, um die Routen (bspw. Login-Route) zu rendern. Damit bleibt Charakterin selbst ohne Template. |
28 | type Renderer interface { | 33 | type Renderer interface { |
29 | RenderLoginPage(w http.ResponseWriter, data map[string]interface{}) | 34 | RenderLoginPage(w http.ResponseWriter, data map[string]interface{}) |
@@ -401,9 +406,15 @@ func (c *Charakterin) DisplayAPICouplePage(w http.ResponseWriter, r *http.Reques | |||
401 | http.Error(w, "403", http.StatusForbidden) | 406 | http.Error(w, "403", http.StatusForbidden) |
402 | return | 407 | return |
403 | } | 408 | } |
409 | |||
410 | service := ps.ByName("type") | ||
411 | if service != ANILIST { | ||
412 | http.Error(w, "Ungueltiger Service", http.StatusNotFound) | ||
413 | return | ||
414 | } | ||
404 | data := make(map[string]interface{}) | 415 | data := make(map[string]interface{}) |
405 | data["user"] = user | 416 | data["user"] = user |
406 | data["name"] = ps.ByName("type") | 417 | data["name"] = service |
407 | c.renderer.RenderAPICouplePage(w, data) | 418 | c.renderer.RenderAPICouplePage(w, data) |
408 | } | 419 | } |
409 | 420 | ||
@@ -419,8 +430,11 @@ func (c *Charakterin) CoupleAPI(w http.ResponseWriter, r *http.Request, ps httpr | |||
419 | return | 430 | return |
420 | } | 431 | } |
421 | switch ps.ByName("type") { | 432 | switch ps.ByName("type") { |
422 | case "Anilist": | 433 | case ANILIST: |
423 | err = user.AnilistClient.CoupleByPin(body["code"][0]) | 434 | err = user.AnilistClient.CoupleByPin(body["code"][0]) |
435 | break | ||
436 | default: | ||
437 | err = errors.New("Ungueltiger Service") | ||
424 | } | 438 | } |
425 | if err != nil { | 439 | if err != nil { |
426 | data := make(map[string]interface{}) | 440 | data := make(map[string]interface{}) |