web

package
v0.0.0-...-842b49f Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeJSON is the content type for JSON
	ContentTypeJSON = "application/json"

	// ContentTypeText is the content type for plain text
	ContentTypeText = "text/plain"
)

Variables

This section is empty.

Functions

func ChiIDGetter

func ChiIDGetter(r *http.Request) (string, error)

ChiIDGetter for chi mux library

func Json

func Json(w http.ResponseWriter, status int, r interface{})

Json to the browser

func JsonError

func JsonError(w http.ResponseWriter, status int, err error)

JsonError to the browser in json format

func Print

func Print(w http.ResponseWriter, status int, ctype string, content []byte)

Print sends data to the browser

func ReadBody

func ReadBody(r *http.Request) ([]byte, error)

ReadBody from an http.Request

func ReadJsonBodyInto

func ReadJsonBodyInto(w http.ResponseWriter, r *http.Request, target interface{}) error

ReadJsonBodyInto reads json body into a target structure

func TimestampHandler

func TimestampHandler(w http.ResponseWriter, r *http.Request)

TimestampHandler is a simple http handler that returns local time. Useful for status checking

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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