initial commit of api

This commit is contained in:
David
2020-08-06 14:15:14 -04:00
parent 5db9d387df
commit a651b9cd73
9 changed files with 420 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package http
import (
"context"
"fmt"
"net/http"
"time"
)
type Server struct {
RateLimiter RateLimiter
server *http.Server
}
func (s *Server) Run() error {
s.server = &http.Server{
Addr: ":8080",
ReadTimeout: 30 * time.Second,
WriteTimeout: 30 * time.Second,
Handler: s.BuildRoutes(),
}
fmt.Println("server listening on :8080")
return s.server.ListenAndServe()
}
func (s *Server) Shutdown(ctx context.Context) error {
return s.server.Shutdown(ctx)
}