Documentation ΒΆ
Index ΒΆ
- Variables
- func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)
- func AuthGoogleHandler(tc *TupaContext) error
- func AuthLinkedinCallback(w http.ResponseWriter, r *http.Request) (map[string]interface{}, error)
- func AuthLinkedinHandler(tc *TupaContext) error
- func FmtBlue(s string) string
- func FmtRed(s string) string
- func FmtYellow(s string) string
- func GenerateRandomStringHelper(length int) (string, error)
- func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)
- func UseGoogleOauth(clientID, clientSecret, redirectURL, googleWentWrongdRedirectURL string, ...)
- func UseLinkedinOauth(clientID, clientSecret, redirectURL, linkedinWentWrongRedirUrl string, ...)
- func WelcomeHandler(tc *TupaContext) error
- func WriteJSONHelper(w http.ResponseWriter, status int, v any) error
- type APIError
- type APIFunc
- type APIServer
- func (a *APIServer) GetGlobalMiddlewares() []MiddlewareFunc
- func (a *APIServer) MakeHTTPHandlerFuncHelper(routeInfo RouteInfo, middlewares MiddlewareChain, ...) http.HandlerFunc
- func (a *APIServer) New()
- func (a *APIServer) RegisterRoutes(routeInfos []RouteInfo)
- func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)
- type Context
- type GoogleAuthResponse
- type GoogleDefaultResponse
- type HTTPMethod
- type LinkedinUserLocale
- type MiddlewareChain
- type MiddlewareFunc
- type RouteInfo
- type TupaContext
- func (tc *TupaContext) NewTupaContext(w http.ResponseWriter, r *http.Request) *TupaContext
- func (tc *TupaContext) Param(param string) string
- func (tc *TupaContext) QueryParam(param string) string
- func (tc *TupaContext) QueryParams() map[string][]string
- func (tc *TupaContext) Request() *http.Request
- func (tc *TupaContext) Response() *http.ResponseWriter
- func (tc *TupaContext) SendString(s string) error
- func (tc *TupaContext) SetRequest(r *http.Request)
- func (tc *TupaContext) SetResponse(w http.ResponseWriter)
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 )
View Source
var AllowedMethods = map[HTTPMethod]bool{ MethodGet: true, MethodPost: true, MethodPut: true, MethodDelete: true, MethodPatch: true, MethodOptions: true, }
Functions ΒΆ
func AddRoutes ΒΆ
func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)
func AuthGoogleHandler ΒΆ
func AuthGoogleHandler(tc *TupaContext) error
func AuthLinkedinCallback ΒΆ
func AuthLinkedinHandler ΒΆ
func AuthLinkedinHandler(tc *TupaContext) error
func UploadFile ΒΆ
func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)
func UseGoogleOauth ΒΆ
func UseLinkedinOauth ΒΆ
func WelcomeHandler ΒΆ
func WelcomeHandler(tc *TupaContext) error
func WriteJSONHelper ΒΆ
func WriteJSONHelper(w http.ResponseWriter, status int, v any) error
Types ΒΆ
type APIFunc ΒΆ
type APIFunc func(*TupaContext) error
type APIServer ΒΆ
type APIServer struct {
// contains filtered or unexported fields
}
func NewAPIServer ΒΆ
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) RegisterRoutes ΒΆ
func (*APIServer) UseGlobalMiddleware ΒΆ
func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)
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 MiddlewareChain ΒΆ
type MiddlewareChain []MiddlewareFunc
func (*MiddlewareChain) Use ΒΆ
func (chain *MiddlewareChain) Use(middleware ...MiddlewareFunc)
type MiddlewareFunc ΒΆ
type RouteInfo ΒΆ
type RouteInfo struct { Path string Method HTTPMethod Handler APIFunc Middlewares []MiddlewareFunc }
type TupaContext ΒΆ
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)
Click to show internal directories.
Click to hide internal directories.