seeker

package
v0.0.0-...-24ca9bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

package seeker is a simplified web browser implementation used to search specifically for text and numerical data.

This implementation is based on a "read-only" style of search where the majority of user input, animations, and other functionality is disabled.

The intention is to provide: - a simple interface for reading data in a web browser with minimal distractions

- saving data to a file, database, or other storage in convenient formats.

- directly saving "data-type" files

- uses Google Search to provide results

- linked to Google Cloud Storage and related services (scripting to manipulate data in the cloud not yet supported.)

- maintain hyperlinks by default.

- simple option to turn on image loading.

- options to control the style sheet used to display all pages.

- command line options and configuration

NOTE: Scripting and automation features of web pages are disabled by default. Most functionality of web pages is unavailable be design.

Index

Constants

This section is empty.

Variables

View Source
var (
	PortString string = fmt.Sprintf("%v:%d", defaultServer, *port)
)

Functions

func ArgServer

func ArgServer(w http.ResponseWriter, req *http.Request)

simple argument server

func DetectContentType

func DetectContentType(data []byte) string

DetectContentType implements the algorithm described at https://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data.

DetectContentType always returns a valid MIME type: if it cannot determine a more specific one, it returns "application/octet-stream".

http.DetectContentType

DetectContentType = func(data []byte) string

func Seek

func Seek(portString string) error

func StatusText

func StatusText(code int) string

StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.

Types

type Any

type Any interface{}

type AnyMap

type AnyMap = map[Any]Any

type AnyType

type AnyType reflect.Type

type AnyTypeMap

type AnyTypeMap = map[AnyType]AnyType

type CloseNotifier

type CloseNotifier = http.CloseNotifier

type File

type File = http.File

type Flusher

type Flusher = http.Flusher

type Handler

type Handler = http.Handler

A Handler responds to an HTTP request.

ServeHTTP should write reply headers and data to the ResponseWriter and then return. Returning signals that the request is finished; it is not valid to use the ResponseWriter or read from the Request.Body after or concurrently with the completion of the ServeHTTP call.

Depending on the HTTP client software, HTTP protocol version, and any intermediaries between the client and the Go server, it may not be possible to read from the Request.Body after writing to the ResponseWriter. Cautious handlers should read the Request.Body first, and then reply.

Except for reading the body, handlers should not modify the provided Request.

If ServeHTTP panics, the server (the caller of ServeHTTP) assumes that the effect of the panic was isolated to the active request. It recovers the panic, logs a stack trace to the server error log, and either closes the network connection or sends an HTTP/2 RST_STREAM, depending on the HTTP protocol. To abort a handler so the client sees an interrupted response but the server doesn't log an error, panic with the value ErrAbortHandler.

 type Handler interface {
		ServeHTTP(ResponseWriter, *Request)
	}

type HandlerFunc

type HandlerFunc = http.HandlerFunc

The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.

type HandlerFunc func(ResponseWriter, *Request)

type HandlerMap

type HandlerMap struct {
	// contains filtered or unexported fields
}
type Header = http.Header

type Hijacker

type Hijacker = http.Hijacker

type LocalTime

type LocalTime struct {
	// contains filtered or unexported fields
}

A LocalTime represents an instant in time with nanosecond precision. It is a modified version of the standard library time package Time type that removes timezone information for performance reasons.

The goal is to create a time type that specifies values that can be used as unique keys in a database or map. From the standard library: "Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values"

Reference: go 1.17.5

Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type time.Time, not *time.Time.

A Time value can be used by multiple goroutines simultaneously except that the methods GobDecode, UnmarshalBinary, UnmarshalJSON and UnmarshalText are not concurrency-safe.

Time instants can be compared using the Before, After, and Equal methods. The Sub method subtracts two instants, producing a Duration. The Add method adds a Time and a Duration, producing a Time.

The zero value of type Time is January 1, year 1, 00:00:00.000000000 UTC. As this time is unlikely to come up in practice, the IsZero method gives a simple way of detecting a time that has not been initialized explicitly.

In addition to the required “wall clock” reading, a Time may contain an optional reading of the current process's monotonic clock, to provide additional precision for comparison or subtraction. See the “Monotonic Clocks” section in the package documentation for details.

Note that the Go == operator compares not just the time instant but also the Location and the monotonic clock reading. Therefore, Time values should not be used as map or database keys without first guaranteeing that the identical Location has been set for all values, which can be achieved through use of the UTC or Local method, and that the monotonic clock reading has been stripped by setting t = t.Round(0). In general, prefer t.Equal(u) to t == u, since t.Equal uses the most accurate comparison available and correctly handles the case when only one of its arguments has a monotonic clock reading.

type Location

type Location struct {
	// contains filtered or unexported fields
}

A Location maps time instants to the zone in use at that time. Typically, the Location represents the collection of time offsets in use in a geographical area. For many Locations the time offset varies depending on whether daylight savings time is in use at the time instant.

type Pusher

type Pusher = http.Pusher

type Request

type Request = http.Request

type Response

type Response = http.Response

type ResponseWriter

type ResponseWriter = http.ResponseWriter

A ResponseWriter interface is used by an HTTP handler to construct an HTTP response.

A ResponseWriter may not be used after the Handler.ServeHTTP method has returned.

type ResponseWriter interface {
	// Header returns the header map that will be sent by
	// WriteHeader. The Header map also is the mechanism with which
	// Handlers can set HTTP trailers.
	//
	// Changing the header map after a call to WriteHeader (or
	// Write) has no effect unless the modified headers are
	// trailers.
	//
	// There are two ways to set Trailers. The preferred way is to
	// predeclare in the headers which trailers you will later
	// send by setting the "Trailer" header to the names of the
	// trailer keys which will come later. In this case, those
	// keys of the Header map are treated as if they were
	// trailers. See the example. The second way, for trailer
	// keys not known to the Handler until after the first Write,
	// is to prefix the Header map keys with the TrailerPrefix
	// constant value. See TrailerPrefix.
	//
	// To suppress automatic response headers (such as "Date"), set
	// their value to nil.
	Header() Header

	// Write writes the data to the connection as part of an HTTP reply.
	//
	// If WriteHeader has not yet been called, Write calls
	// WriteHeader(http.StatusOK) before writing the data. If the Header
	// does not contain a Content-Type line, Write adds a Content-Type set
	// to the result of passing the initial 512 bytes of written data to
	// DetectContentType. Additionally, if the total size of all written
	// data is under a few KB and there are no Flush calls, the
	// Content-Length header is added automatically.
	//
	// Depending on the HTTP protocol version and the client, calling
	// Write or WriteHeader may prevent future reads on the
	// Request.Body. For HTTP/1.x requests, handlers should read any
	// needed request body data before writing the response. Once the
	// headers have been flushed (due to either an explicit Flusher.Flush
	// call or writing enough data to trigger a flush), the request body
	// may be unavailable. For HTTP/2 requests, the Go HTTP server permits
	// handlers to continue to read the request body while concurrently
	// writing the response. However, such behavior may not be supported
	// by all HTTP/2 clients. Handlers should read before writing if
	// possible to maximize compatibility.
	Write([]byte) (int, error)

	// WriteHeader sends an HTTP response header with the provided
	// status code.
	//
	// If WriteHeader is not called explicitly, the first call to Write
	// will trigger an implicit WriteHeader(http.StatusOK).
	// Thus explicit calls to WriteHeader are mainly used to
	// send error codes.
	//
	// The provided code must be a valid HTTP 1xx-5xx status code.
	// Only one header may be written. Go does not currently
	// support sending user-defined 1xx informational headers,
	// with the exception of 100-continue response header that the
	// Server sends automatically when the Request.Body is read.
	WriteHeader(statusCode int)
}

type Settings

type Settings struct {
	// contains filtered or unexported fields
}

func Config

func Config(portString string, handlers HandlerMap) *Settings

type StringMap

type StringMap struct {
	// contains filtered or unexported fields
}

type Styler

type Styler interface {
	Parse([]byte) ([]byte, error)
}

type Time

type Time struct {
	// contains filtered or unexported fields
}

type TimeDataPoint

type TimeDataPoint interface{}

TimeDataPoint represents data related to a specific time interval.

type TimeMap

type TimeMap map[int64]TimeDataPoint

timeMap is an ordered map of time series values

func (TimeMap) Get

func (t TimeMap) Get(time int64) (TimeDataPoint, bool)

type URL

type URL = url.URL

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL