diff options
Diffstat (limited to 'api/router.go')
| -rw-r--r-- | api/router.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/api/router.go b/api/router.go new file mode 100644 index 0000000..9ea7ac0 --- /dev/null +++ b/api/router.go @@ -0,0 +1,27 @@ +package api + +import ( + "net/http" + + "git.leonardobishop.net/history/api/handlers" + "git.leonardobishop.net/history/api/middleware" + "git.leonardobishop.net/history/internal/config" + "git.leonardobishop.net/history/pkg/entries" + "git.leonardobishop.net/history/pkg/html" +) + +type ApiServices struct { + EntiresService entries.Service + HtmlService html.Service + + Config config.Config +} + +func NewServer(api ApiServices) *http.ServeMux { + mux := http.NewServeMux() + + mux.HandleFunc("POST /record", middleware.Cors(handlers.RecordEntry(api.EntiresService, api.Config.Token))) + mux.HandleFunc("GET /html", handlers.GetEntriesHtml(api.EntiresService, api.HtmlService)) + + return mux +} |
