api

package
v0.0.0-...-6b835ca Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, s suite.TestingSuite)

Run run test suites

func SetupSuite

func SetupSuite(s *Suite)

SetupSuite before suite processes

func TearDownSuite

func TearDownSuite(s *Suite)

TearDownSuite after suite processes

func UserAuth

func UserAuth(s *Suite)

UserAuth generate test request auth provides

Types

type API

type API struct {
	App     *cmn.App
	Router  *Router
	JWTAuth *JWTAuth
	Auth    struct {
		ID int64
	}
}

API rest api structure

func NewAPI

func NewAPI(app *cmn.App) *API

NewAPI building api

func (*API) JSONBody

func (a *API) JSONBody(ctx *fasthttp.RequestCtx, model interface{})

JSONBody parse given model request body

func (*API) JSONResponse

func (a *API) JSONResponse(ctx *fasthttp.RequestCtx, response model.ResponseInterface, status int)

JSONResponse building json response

func (*API) Paginate

func (a *API) Paginate(ctx *fasthttp.RequestCtx, orderFields ...string) (model.Pagination, map[string]string, error)

Paginate request paginate build

func (*API) ParseQuery

func (a *API) ParseQuery(ctx *fasthttp.RequestCtx) map[string]string

ParseQuery parse url query string

type ContentType

type ContentType string

ContentType request content type for test api request

const (
	// JSON Content type for api request
	JSON ContentType = "application/json"
	// XML Content type for api request
	XML ContentType = "application/xml"
	// HTML Content type for api request
	HTML ContentType = "text/html"
	// FormData Multipart/form-data Content Type for api request
	FormData ContentType = "multipart/form-data"
)

type Controller

type Controller interface {
	Index(ctx *fasthttp.RequestCtx)
	Show(ctx *fasthttp.RequestCtx)
	Create(ctx *fasthttp.RequestCtx)
	Update(ctx *fasthttp.RequestCtx)
	Delete(ctx *fasthttp.RequestCtx)
}

Controller rest api interface

type FileController

type FileController struct {
	Controller
	*API
}

FileController job files api controller

func (FileController) Create

func (c FileController) Create(ctx *fasthttp.RequestCtx)

Create job file

func (FileController) Delete

func (c FileController) Delete(ctx *fasthttp.RequestCtx)

Delete job file

func (FileController) Index

func (c FileController) Index(ctx *fasthttp.RequestCtx)

Index list all job files

func (FileController) Show

func (c FileController) Show(ctx *fasthttp.RequestCtx)

Show job file

func (FileController) Update

func (c FileController) Update(ctx *fasthttp.RequestCtx)

Update job file

type FileLogController

type FileLogController struct {
	Controller
	*API
}

FileLogController file log api controller

func (FileLogController) Index

func (c FileLogController) Index(ctx *fasthttp.RequestCtx)

Index list all file logs

type HomeController

type HomeController struct {
	Controller
	*API
}

HomeController base controller

func (HomeController) Index

func (c HomeController) Index(ctx *fasthttp.RequestCtx)

Index api base route

type JWTAuth

type JWTAuth struct {
	API    *API
	Method *jwt.SigningMethodHMAC
	Secret string
	Expire int64
}

JWTAuth authentication mechanism

func NewJWTAuth

func NewJWTAuth(api *API) *JWTAuth

NewJWTAuth generate jwt auth

func (JWTAuth) Generate

func (a JWTAuth) Generate(args ...interface{}) (string, error)

Generate generate jwt token with mapClaims

func (JWTAuth) Parse

func (a JWTAuth) Parse(tokenString string) (map[string]interface{}, int)

Parse token string parse mapClaims expire check

func (JWTAuth) Verify

func (a JWTAuth) Verify(next phi.HandlerFunc) phi.HandlerFunc

Verify verify bearer token in requests

type JobController

type JobController struct {
	Controller
	*API
}

JobController user defined background job api controller

func (JobController) Create

func (c JobController) Create(ctx *fasthttp.RequestCtx)

Create user defined background job

func (JobController) Delete

func (c JobController) Delete(ctx *fasthttp.RequestCtx)

Delete user defined background job

func (JobController) Index

func (c JobController) Index(ctx *fasthttp.RequestCtx)

Index list all user defined background jobs

func (JobController) Show

func (c JobController) Show(ctx *fasthttp.RequestCtx)

Show a user defined background job

type JobDetailController

type JobDetailController struct {
	Controller
	*API
}

JobDetailController user defined background job detail api controller

func (JobDetailController) Create

func (c JobDetailController) Create(ctx *fasthttp.RequestCtx)

Create detail for user defined background job

type LoginController

type LoginController struct {
	Controller
	*API
}

LoginController user authentication controller

func (LoginController) Create

func (c LoginController) Create(ctx *fasthttp.RequestCtx)

Create user sign in method

type Method

type Method string

Method request method for test api request

const (
	// Options method for api request
	Options Method = "OPTIONS"
	// Post method for api request
	Post Method = "POST"
	// Get method for api request
	Get Method = "GET"
	// Put method for api request
	Put Method = "PUT"
	// Delete method for api request
	Delete Method = "DELETE"
)

type Router

type Router struct {
	API     *API
	Server  *fasthttp.Server
	Addr    string
	Handler *phi.Mux
}

Router api router structure

func NewRouter

func NewRouter(api *API) *Router

NewRouter building api router

type Suite

type Suite struct {
	suite.Suite
	API  *API
	Auth struct {
		User  *model2.User
		Token string
	}
}

Suite application test structure

func NewSuite

func NewSuite() *Suite

NewSuite build test application

func (*Suite) File

func (s *Suite) File(method Method, path string, arg interface{}, fileParam ...string) *TestResponse

File api form-data request

func (*Suite) JSON

func (s *Suite) JSON(method Method, path string, arg interface{}) *TestResponse

JSON api json request

type TestResponse

type TestResponse struct {
	RequestError error
	Success      model.ResponseSuccess
	Error        model.ResponseError
	Other        interface{}
	Status       int
}

TestResponse response model for test api request

type TokenController

type TokenController struct {
	Controller
	*API
}

TokenController user authentication token controller

func (TokenController) Create

func (c TokenController) Create(ctx *fasthttp.RequestCtx)

Create generate user jwt method

type UploadController

type UploadController struct {
	Controller
	*API
}

UploadController file upload api controller

func (UploadController) Create

func (c UploadController) Create(ctx *fasthttp.RequestCtx)

Create file upload method

func (UploadController) DirIndex

func (c UploadController) DirIndex(ctx *fasthttp.RequestCtx)

DirIndex directory list in lib path

Jump to

Keyboard shortcuts

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