api

package
v0.0.0-...-07785dc Latest Latest
Warning

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

Go to latest
Published: May 12, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondWithError

func RespondWithError(w http.ResponseWriter, code int, message string)

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, code int, payload interface{})

Types

type API

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

API struct

func NewAPI

func NewAPI(db *models.DB) *API

NewAPI - Returns and instance of *API

func (*API) AuthJWTMiddleware

func (api *API) AuthJWTMiddleware(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*API) GetUserFromContext

func (api *API) GetUserFromContext(req *http.Request) *models.User

GetUserFromContext - return User reference from header token

func (*API) ProjectsHandler

func (api *API) ProjectsHandler(w http.ResponseWriter, req *http.Request)

func (*API) UserInfoHandler

func (api *API) UserInfoHandler(w http.ResponseWriter, req *http.Request)

UserInfoHandler - Return user details as marshalled to JSON.

func (*API) UserSignup

func (api *API) UserSignup(w http.ResponseWriter, req *http.Request)

UserSignup -

type ProjectJSON

type ProjectJSON struct {
	Name   string `json:"name"`
	Active bool   `json:"active"`
}

ProjectJSON - JSON data expected for login/signup

type Token

type Token struct {
	AccessToken string `json:"access_token"`
}

Token - JSON data for JWT access token

type UserJSON

type UserJSON struct {
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

UserJSON - JSON data expected for login/signup

Jump to

Keyboard shortcuts

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