Documentation ¶
Overview ¶
Package server provides http handlers and middlewares.
Index ¶
- Variables
- func WithBotsAndCrawlersBlocking(next http.HandlerFunc) http.HandlerFunc
- func WithRequestHeadersLogging(next http.HandlerFunc) http.HandlerFunc
- type Server
- func (s *Server) FeedHandler() http.HandlerFunc
- func (s *Server) FileHandler(path string) http.HandlerFunc
- func (s *Server) HTMLHandler() http.HandlerFunc
- func (s *Server) JSONHandler(enableCors bool) http.HandlerFunc
- func (s *Server) LinkHandler(key *[32]byte) http.HandlerFunc
- func (s *Server) SitemapHandler(key *[32]byte) http.HandlerFunc
Constants ¶
This section is empty.
Variables ¶
View Source
var CrawlerAliases = []string{"bot", "crawler", "spider", "trendsmapresolver", "fetcher"}
CrawlerAliases are the names of possible crawler's user agents
View Source
var RequiredHeaders = []string{"Cf-Ipcountry", "Cf-Connecting-Ip", "X-Forwarded-For"}
RequiredHeaders are the headers we need to care about
Functions ¶
func WithBotsAndCrawlersBlocking ¶
func WithBotsAndCrawlersBlocking(next http.HandlerFunc) http.HandlerFunc
WithBotsAndCrawlersBlocking blocks bots and crawlers based on user agents of requests
func WithRequestHeadersLogging ¶
func WithRequestHeadersLogging(next http.HandlerFunc) http.HandlerFunc
WithRequestHeadersLogging logs headers from RequiredHeaders
Types ¶
type Server ¶
Server will have several handlers
func (*Server) FeedHandler ¶
func (s *Server) FeedHandler() http.HandlerFunc
FeedHandler serves rss|atom|json feeds from items
func (*Server) FileHandler ¶
func (s *Server) FileHandler(path string) http.HandlerFunc
FileHandler serves a file from a given path
func (*Server) HTMLHandler ¶
func (s *Server) HTMLHandler() http.HandlerFunc
HTMLHandler serves html
func (*Server) JSONHandler ¶
func (s *Server) JSONHandler(enableCors bool) http.HandlerFunc
JSONHandler serves json
func (*Server) LinkHandler ¶
func (s *Server) LinkHandler(key *[32]byte) http.HandlerFunc
LinkHandler redirects encrypted links generated by 8hrs.xyz
func (*Server) SitemapHandler ¶
func (s *Server) SitemapHandler(key *[32]byte) http.HandlerFunc
SitemapHandler serves sitemap.xml
Click to show internal directories.
Click to hide internal directories.