Documentation ¶
Overview ¶
Package app serves the clamber package as an API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefinedRoutes = Routes{ Route{ "Initiate", "GET", "/search", SearchHandler, []string{ "url", "{url}", "depth", "{depth}", }, }, }
DefinedRoutes contains defined routes data
Functions ¶
func HttpResponseLogger ¶
HttpResponseLogger creates a custom logger which outputs HTTP response info as a json log to stdout.
func SearchHandler ¶
func SearchHandler(w http.ResponseWriter, r *http.Request)
SearchHandler function handles /search endpoint. Initiates a database connection, tries to find the url in the database with the required depth, and if it doesn't exist, initiate a crawl.
Types ¶
type Flags ¶
Flags holds the app Flags
var ( // AppFlags makes a global Flag struct AppFlags Flags )
type Query ¶
type Query struct { Url string `json:"url"` Depth int `json:"depth"` DisplayDepth int `json:"display_depth"` StatusCode int `json:"statusCode"` Results *common.Page `json:"results"` }
Query contains queried URL, depth and the resulting page data
type RichResponseWriter ¶
type RichResponseWriter struct { http.ResponseWriter StatusCode int }
RichResponseWriter encapsulates status code and Response Writer
func NewRichResponseWriter ¶
func NewRichResponseWriter(w http.ResponseWriter) *RichResponseWriter
NewRichResponseWriter function creates a new RichResponseWriter
func (*RichResponseWriter) WriteHeader ¶
func (w *RichResponseWriter) WriteHeader(code int)
WriteHeader function Writers specified header to response
Click to show internal directories.
Click to hide internal directories.