api

package
v0.0.0-...-52143c3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRouter

func BuildRouter(app *App) *chi.Mux

BuildRouter builds the router

func JSONError

func JSONError(w http.ResponseWriter, errStr string, code int)

JSONError renders json with error

func JSONOk

func JSONOk(w http.ResponseWriter, v interface{})

JSONOk renders json with 200 ok

func LoadEnv

func LoadEnv(filename string) error

LoadEnv loads env variables from .env file

func StartServer

func StartServer() error

StartServer starts the server

Types

type App

type App struct {
	GCPSvc GCPSvc
}

func (*App) HandleError

func (app *App) HandleError(w http.ResponseWriter, r *http.Request, err error)

HandleError handles errors

func (*App) HandleSaveText

func (app *App) HandleSaveText(w http.ResponseWriter, r *http.Request)

HandleSaveText saves text

type CtxKey

type CtxKey string

CtxKey context key

type GCPService

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

GCPService GCP Service struct

func NewGCPService

func NewGCPService() (*GCPService, error)

NewGCPService inits gcp service

func (*GCPService) CreateFile

func (svc *GCPService) CreateFile(ctx context.Context, name, content string) error

type GCPSvc

type GCPSvc interface {
	CreateFile(ctx context.Context, name, content string) error
}

GCPSvc GCP Service interface

type JSONErr

type JSONErr struct {
	Err string `json:"err"`
}

JSONErr err

type SaveTextReqData

type SaveTextReqData struct {
	Name    string `json:"name"`
	Content string `json:"content"`
}

Jump to

Keyboard shortcuts

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