tupa

package module
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 23 Imported by: 1

README ΒΆ

πŸ‡§πŸ‡· TupΓ£ ⚑️

alt text

πŸ‡§πŸ‡· Na mitologia Tupi Guarani, TupΓ£ Γ© o deus do trovΓ£o, criador de deuses, da humanidade, dos cΓ©us, mares, mundo animal e vegetal. O framework TupΓ£ foi criado para te auxiliar na criação de projetos grandiosos e na velocidade da luz ⚑️

πŸ‡ΊπŸ‡Έ In Tupi-Guarani mythology (a Brazilian indigenous tribe), TupΓ£ is the god of thunder, creator of gods, humanity, the skies, seas, animals and forests. The TupΓ£ framework was created to assist you in the development of ambitious projects at the speed of light ⚑️

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

This section is empty.

Variables ΒΆ

View Source
var (
	GoogleOauthConfig = &oauth2.Config{
		ClientID:     "",
		ClientSecret: "",
		RedirectURL:  "",
		Scopes:       []string{""},
		Endpoint:     google.Endpoint,
	}
	GoogleWentWrongRedirUrl string

	LinkedinOauthConfig = &oauth2.Config{
		ClientID:     "",
		ClientSecret: "",
		RedirectURL:  "",
		Scopes:       []string{""},
		Endpoint:     linkedin.Endpoint,
	}
	LinkedingWentWrongRedirUrl string
)

Functions ΒΆ

func AddRoutes ΒΆ

func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)

func AuthGoogleHandler ΒΆ

func AuthGoogleHandler(tc *TupaContext) error

func AuthLinkedinCallback ΒΆ

func AuthLinkedinCallback(w http.ResponseWriter, r *http.Request) (map[string]interface{}, error)

func AuthLinkedinHandler ΒΆ

func AuthLinkedinHandler(tc *TupaContext) error

func FmtBlue ΒΆ

func FmtBlue(s string) string

func FmtRed ΒΆ

func FmtRed(s string) string

func FmtYellow ΒΆ

func FmtYellow(s string) string

func GenerateRandomStringHelper ΒΆ

func GenerateRandomStringHelper(length int) (string, error)

func UploadFile ΒΆ

func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)

func UseGoogleOauth ΒΆ

func UseGoogleOauth(clientID, clientSecret, redirectURL, googleWentWrongdRedirectURL string, scopes []string)

func UseLinkedinOauth ΒΆ

func UseLinkedinOauth(clientID, clientSecret, redirectURL, linkedinWentWrongRedirUrl string, scopes []string)

func WelcomeHandler ΒΆ

func WelcomeHandler(tc *TupaContext) error

func WriteJSONHelper ΒΆ

func WriteJSONHelper(w http.ResponseWriter, status int, v any) error

Types ΒΆ

type APIError ΒΆ

type APIError struct {
	Error string
}

type APIFunc ΒΆ

type APIFunc func(*TupaContext) error

type APIServer ΒΆ

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

func NewAPIServer ΒΆ

func NewAPIServer(listenAddr string) *APIServer

func (*APIServer) GetGlobalMiddlewares ΒΆ

func (a *APIServer) GetGlobalMiddlewares() []MiddlewareFunc

func (*APIServer) MakeHTTPHandlerFuncHelper ΒΆ

func (a *APIServer) MakeHTTPHandlerFuncHelper(routeInfo RouteInfo, middlewares MiddlewareChain, globalMiddlewares MiddlewareChain) http.HandlerFunc

func (*APIServer) New ΒΆ

func (a *APIServer) New()

func (*APIServer) RegisterRoutes ΒΆ

func (a *APIServer) RegisterRoutes(routeInfos []RouteInfo)

func (*APIServer) UseGlobalMiddleware ΒΆ

func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)

type Context ΒΆ

type Context interface {
	Request() *http.Request
	Response() http.ResponseWriter
	SendString(s string) error
	Param(param string) string
	QueryParam(param string) string
	QueryParams() map[string][]string
	SetRequest(r *http.Request)
	SetResponse(w http.ResponseWriter)
}

type GoogleAuthResponse ΒΆ

type GoogleAuthResponse struct {
	UserInfo GoogleDefaultResponse
	Token    *oauth2.Token
}

func AuthGoogleCallback ΒΆ

func AuthGoogleCallback(tc *TupaContext) (*GoogleAuthResponse, error)

type GoogleDefaultResponse ΒΆ

type GoogleDefaultResponse struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
	HostedDomain  string `json:"hd"`
}

type HTTPMethod ΒΆ

type HTTPMethod string
const (
	MethodGet     HTTPMethod = http.MethodGet
	MethodPost    HTTPMethod = http.MethodPost
	MethodPut     HTTPMethod = http.MethodPut
	MethodDelete  HTTPMethod = http.MethodDelete
	MethodPatch   HTTPMethod = http.MethodPatch
	MethodOptions HTTPMethod = http.MethodOptions
)

type LinkedinUserLocale ΒΆ

type LinkedinUserLocale struct {
	Country  string `json:"country"`
	Language string `json:"language"`
}

type MiddlewareChain ΒΆ

type MiddlewareChain []MiddlewareFunc

func (*MiddlewareChain) Use ΒΆ

func (chain *MiddlewareChain) Use(middleware ...MiddlewareFunc)

type MiddlewareFunc ΒΆ

type MiddlewareFunc func(APIFunc) APIFunc

type RouteInfo ΒΆ

type RouteInfo struct {
	Path        string
	Method      HTTPMethod
	Handler     APIFunc
	Middlewares []MiddlewareFunc
}

func GetRoutes ΒΆ

func GetRoutes() []RouteInfo

type TupaContext ΒΆ

type TupaContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (*TupaContext) NewTupaContext ΒΆ

func (tc *TupaContext) NewTupaContext(w http.ResponseWriter, r *http.Request) *TupaContext

func (*TupaContext) Param ΒΆ

func (tc *TupaContext) Param(param string) string

func (*TupaContext) QueryParam ΒΆ

func (tc *TupaContext) QueryParam(param string) string

func (*TupaContext) QueryParams ΒΆ

func (tc *TupaContext) QueryParams() map[string][]string

func (*TupaContext) Request ΒΆ

func (tc *TupaContext) Request() *http.Request

func (*TupaContext) Response ΒΆ

func (tc *TupaContext) Response() *http.ResponseWriter

func (*TupaContext) SendString ΒΆ

func (tc *TupaContext) SendString(s string) error

func (*TupaContext) SetRequest ΒΆ

func (tc *TupaContext) SetRequest(r *http.Request)

func (*TupaContext) SetResponse ΒΆ

func (tc *TupaContext) SetResponse(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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