app

package
v0.0.0-...-0b87ad2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package app for pkid app

Package app for pkid app

Package app for pkid app

Package app for c4s backend app

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapFunc

func WrapFunc(a Handler) http.HandlerFunc

WrapFunc is a helper wrapper to make implementing handlers easier

Types

type App

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

App for all dependencies of backend server

func NewApp

func NewApp(ctx context.Context, configFile string) (app *App, err error)

NewApp creates new server app all configurations

func (*App) Start

func (a *App) Start(ctx context.Context) (err error)

Start starts the app

type Handler

type Handler func(r *http.Request) (interface{}, Response)

Handler interface

type Response

type Response interface {
	Status() int
	Err() error

	// header getter
	Header() http.Header
	// header setter
	WithHeader(k, v string) Response
}

Response interface

func BadRequest

func BadRequest(err error) Response

BadRequest result

func Created

func Created() Response

Created return a created response

func Deleted

func Deleted() Response

Deleted return a no content response

func Error

func Error(err error, code ...int) Response

Error generic error response

func InternalServerError

func InternalServerError(err error) Response

InternalServerError result

func NotFound

func NotFound(err error) Response

NotFound response

func Ok

func Ok() Response

Ok return a ok response

func UnAuthorized

func UnAuthorized(err error) Response

UnAuthorized response

type ResponseMsg

type ResponseMsg struct {
	Message string      `json:"msg"`
	Data    interface{} `json:"data,omitempty"`
}

ResponseMsg holds messages and needed data

Jump to

Keyboard shortcuts

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