api

package
v0.0.0-...-ea708a5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 16 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, osuApi osuapi.Client, secretCI string) 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

	OsuAPI osuapi.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) CheckSecret

func (c *Context) CheckSecret(token string) bool

CheckSecret checks secretCI key

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