Documentation ¶
Index ¶
- Constants
- Variables
- func LogError(r *http.Request, err error)
- func RunDebugServer() error
- func SendError(w http.ResponseWriter, r *http.Request, err error)
- func SendJSON(w io.Writer, data interface{}) error
- type Server
- func (s *Server) Close() error
- func (s *Server) HandleCommentEvent(ctx context.Context, hand pa.SubscriptionService, event pa.Event) error
- func (s *Server) HandleSubBlogEvent(ctx context.Context, hand pa.SubscriptionService, event pa.Event) error
- func (s *Server) NewOAuthConfig(source string) *oauth2.Config
- func (s *Server) Open() error
- func (s *Server) RegisterCronJon(spec string, cmd func()) error
- func (s *Server) UseTLS() bool
Constants ¶
const ServerShutdownTime = 3 * time.Second
ServerShutdownTime is the time the server allows processes to finish before shuting down.
Variables ¶
var ReposEndpoint string = "https://api.github.com/users/Lambels/repos"
ReposEndpoint represents the endpoint to get repos for projects state, configurable for tests.
Functions ¶
func RunDebugServer ¶
func RunDebugServer() error
RunDebugServer runs a debug server on port 8000 blocking function.
Types ¶
type Server ¶
type Server struct { // server address. Addr string Domain string // Services used by the http package. AuthService pa.AuthService UserService pa.UserService BlogService pa.BlogService SubBlogService pa.SubBlogService CommentService pa.CommentService EventService pa.EventService SubscriptionService pa.SubscriptionService EmailService pa.EmailService ProjectService pa.ProjectService ProjectsFileSystem pa.FileService BlogsFileSystem pa.FileService // contains filtered or unexported fields }
Server represents a backend api HTTP service which wraps all our HTTP functionality.
func NewServer ¶
NewServer registers all routes and returns a new server with the conf configurations.
func (*Server) HandleCommentEvent ¶
func (s *Server) HandleCommentEvent(ctx context.Context, hand pa.SubscriptionService, event pa.Event) error
HandleCommentEvent handels the pa.EventTopicNewComment -> ./event.go. sends an email to all subscribers.
func (*Server) HandleSubBlogEvent ¶
func (s *Server) HandleSubBlogEvent(ctx context.Context, hand pa.SubscriptionService, event pa.Event) error
HandleSubBlogtEvent handels the pa.EventTopicNewSubBlog -> ./event.go. sends an email to all subscribers.
func (*Server) NewOAuthConfig ¶
NewOAuthConfig returns an oauth2.0 config object to start the oauth2.0 authorization flow. source determines the provider config. returns an empty config if not found but that should never happen.
func (*Server) RegisterCronJon ¶
RegisterCronJob registers a new job to s.cron, can be call regardless if cron is or isnt running.