api

package
v0.0.0-...-d475bae Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package api is a template API for Crafting Sandbox.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(c *gin.Context)

BadRequest responds with error status code 400, Bad Request.

func Database

func Database() (*sql.DB, error)

Database creates a new database connection.

func Init

func Init(ctx Context)

Initialize server.

func InternalServerError

func InternalServerError(c *gin.Context)

InternalServerError responds with error status code 500, Internal Server Error.

func NotFound

func NotFound(c *gin.Context)

NotFound responds with error status code 404, Not Found.

func Ping

func Ping(c *gin.Context)

Handles GET requests for /ping?ping=<queryString>.

func Render

func Render(c *gin.Context, indent bool, obj interface{})

Render applies indentation settings to response.

func SetupMySQLConfig

func SetupMySQLConfig()

SetupMySQLConfig updates mysqlConf using environment variables.

Types

type Context

type Context struct {
	Mode string
	Port string
}

Router mode and server port info.

type Error

type Error struct {
	Code    int    `json:"code"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

Error is a custom error structure.

type Route

type Route struct {
	Method   string
	Endpoint string
	Handler  gin.HandlerFunc
}

A routing model.

type Routes

type Routes []Route

A collection of routes.

Jump to

Keyboard shortcuts

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