api

package
v0.0.0-...-5e79193 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package api contains the general framework for writing handlers in the CheeseGull API.

Index

Constants

This section is empty.

Variables

View Source
var Version = "v2.DEV"

Version is set by main and it is given to requests at /

Functions

func CreateHandler

func CreateHandler(db, searchDB *sql.DB, house *housekeeper.House, dlc *downloader.Client) http.Handler

CreateHandler creates a new http.Handler using the handlers registered through GET and POST.

func GET

func GET(path string, f func(c *Context))

GET registers a handler for a GET request.

func POST

func POST(path string, f func(c *Context))

POST registers a handler for a POST request.

Types

type Context

type Context struct {
	Request  *http.Request
	DB       *sql.DB
	SearchDB *sql.DB
	House    *housekeeper.House
	DLClient *downloader.Client
	// contains filtered or unexported fields
}

Context is the information that is passed to all request handlers in relation to the request, and how to answer it.

func (*Context) Code

func (c *Context) Code(i int)

Code sets the response's code.

func (*Context) Err

func (c *Context) Err(err error)

Err attempts to log an error to Sentry, as well as stdout.

func (*Context) Param

func (c *Context) Param(s string) string

Param retrieves a parameter in the URL's path.

func (*Context) ReadHeader

func (c *Context) ReadHeader(s string) string

ReadHeader reads a header from the request.

func (*Context) Write

func (c *Context) Write(b []byte) (int, error)

Write writes content to the response body.

func (*Context) WriteHeader

func (c *Context) WriteHeader(key, value string)

WriteHeader sets a header in the response.

func (*Context) WriteJSON

func (c *Context) WriteJSON(code int, v interface{}) error

WriteJSON writes JSON to the response.

Directories

Path Synopsis
Package download handles the API call to download an osu! beatmap set.
Package download handles the API call to download an osu! beatmap set.
Package metadata handles API request that search for metadata regarding osu! beatmaps.
Package metadata handles API request that search for metadata regarding osu! beatmaps.

Jump to

Keyboard shortcuts

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