summaryrefslogtreecommitdiff
path: root/internal/api/server.go
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-03-17 11:33:06 +0100
committerLibravatar tsmethurst <tobi.smethurst@klarrio.com>2021-03-17 11:33:06 +0100
commiteb2ff2ab23a70298c65f19d52b76c794b2f4937c (patch)
treec58a5039b91e11589b4a47a99803530b0cea3b07 /internal/api/server.go
parentadd liberapay widgets (diff)
downloadgotosocial-eb2ff2ab23a70298c65f19d52b76c794b2f4937c.tar.xz
Some more messing around with oauth2
Diffstat (limited to 'internal/api/server.go')
-rw-r--r--internal/api/server.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/internal/api/server.go b/internal/api/server.go
index 8af9e75fa..9073618f0 100644
--- a/internal/api/server.go
+++ b/internal/api/server.go
@@ -19,16 +19,13 @@
package api
import (
- "net/http"
-
"github.com/gin-gonic/gin"
"github.com/gotosocial/gotosocial/internal/config"
"github.com/sirupsen/logrus"
)
type Server interface {
- AttachHTTPHandler(method string, path string, handler http.HandlerFunc)
- AttachGinHandler(method string, path string, handler gin.HandlerFunc)
+ AttachHandler(method string, path string, handler gin.HandlerFunc)
// AttachMiddleware(handler gin.HandlerFunc)
GetAPIGroup() *gin.RouterGroup
Start()
@@ -60,12 +57,12 @@ func (s *server) Stop() {
// todo: shut down gracefully
}
-func (s *server) AttachHTTPHandler(method string, path string, handler http.HandlerFunc) {
- s.engine.Handle(method, path, gin.WrapH(handler))
-}
-
-func (s *server) AttachGinHandler(method string, path string, handler gin.HandlerFunc) {
- s.engine.Handle(method, path, handler)
+func (s *server) AttachHandler(method string, path string, handler gin.HandlerFunc) {
+ if method == "ANY" {
+ s.engine.Any(path, handler)
+ } else {
+ s.engine.Handle(method, path, handler)
+ }
}
func New(config *config.Config, logger *logrus.Logger) Server {