Documentation ¶
Index ¶
- Constants
- type Auth
- type Guarded
- type OAuth
- type Profiles
- func (u Profiles) Create(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Profiles) Delete(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Profiles) Get(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Profiles) GetAll(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Profiles) GetForUser(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Profiles) Update(w http.ResponseWriter, r *http.Request, params map[string]string)
- type Sessions
- func (s Sessions) Get(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (s Sessions) GetAll(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (s Sessions) Login(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (s Sessions) Logout(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (s Sessions) LogoutWithJSON(w http.ResponseWriter, r *http.Request, params map[string]string)
- type Users
- func (u Users) Create(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) Delete(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) Get(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) GetAll(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) GetLimited(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) Update(w http.ResponseWriter, r *http.Request, params map[string]string)
- func (u Users) UpdatePassword(w http.ResponseWriter, r *http.Request, params map[string]string)
Constants ¶
const ( ResponsePerPageName = "total" PerPageName = "page" )
contains specific constant names for usage in pkg.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct { handlers.BearerAuth Next func(w http.ResponseWriter, r *http.Request, params map[string]string) }
Auth defines an handler which provides authorization handling for a request, needing user authentication.
func (Auth) CheckAuthorization ¶
CheckAuthorization handles receiving requests to verify user authorization.
Service API
HTTP Method: GET Header:
{ "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN>
type Guarded ¶
type Guarded struct { SessionName string CookieName string CookieSecret string Cookies sessions.CookieStore Log sink.Sink }
Guarded defines a struct which exposes a session secured request life cycle where a request made will be guarded with specific data from a underline session and will be validated when receiving response.
type OAuth ¶
OAuth defines a controller which handles the incoming request that it contains the giving "secret" within it's data.
type Profiles ¶
Profiles exposes a central handle for which the API exposes request for profiles.
func (Profiles) Create ¶
Create handles receiving requests to create a user from the server.
Service API HTTP Method: POST Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /profiles/ Body: { "first_name":"", "last_name":"", "user_id":"", "email":"", "address":"", } Response: (Success, 200) Body: { "first_name":"", "last_name":"", "user_id":"", "public_id":"", "email":"", "address":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Profiles) Delete ¶
Delete handles receiving requests to removes a user from the server.
Service API HTTP Method: DELETE Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /profile/:public_id Body: None Response: (Success, 201) Body: None Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Profiles) Get ¶
Get handles receiving requests to get a users from the db.
Service API HTTP Method: GET Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /profiles/:public_id Body: None Response: (Success, 200) Body: { "public_id":"", "private_id":"", "hash":"", "email":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Profiles) GetAll ¶
GetAll handles receiving requests to get all users from the db.
Service API HTTP Method: GET Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /admin/profiles/ Body: None Response: (Success, 200) Body: { page: 1, total: 100, responsePerPage: 24, records: [{ "first_name":"", "last_name":"", "user_id":"", "profile_id":"", "email":"", "address":"", }] } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Profiles) GetForUser ¶
GetForUser handles receiving requests to get a user's profile from the backend.
Service API HTTP Method: GET Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /profile/users/:user_id Body: None Response: (Success, 200) Body: { "public_id":"", "private_id":"", "hash":"", "email":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Profiles) Update ¶
Update handles receiving requests to update a user identified by it's public_id.
Service API HTTP Method: PUT Header: { "Authorization":"Bearer <TOKEN>", } WHERE: <TOKEN> = <USERID>:<SESSIONTOKEN> Request: Path: /profile/:public_id Body: { "first_name":"", "last_name":"", "public_id":"", "email":"", "address":"", } Response: (Success, 201) Body: None Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
type Sessions ¶
Sessions exposes a central handle for which requests are served to all requests.
func (Sessions) Get ¶
Get handles receiving requests to get a sessions from the db.
Service API HTTP Method: GET Request: Path: /admin/sessions/:user_id Body: None Response: (Success, 200) Body: { "user_id":"", "public_id":"", "expires":"", "token":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Sessions) GetAll ¶
GetAll handles receiving requests to get all sessions from the db.
Service API HTTP Method: GET Request: Path: /admin/sessions/ Body: None Response: (Success, 200) Body: { page: 1, total: 100, responsePerPage: 24, records: [{ "user_id":"", "public_id":"", "expires":"", "token":"", }] } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Sessions) Login ¶
Login handles receiving requests to create a new session for a user from the server.
Service API HTTP Method: POST Request: Path: /sessions/login Body: { "email": "", "password": "" } Response: (Success, 201) Body: { "type":"Bearer", "expires":"", "token":"", } Response: (Failure, 500) Body: `{ "status":"", "title":"", "message":"", }
func (Sessions) Logout ¶
Logout handles receiving requests to end a user session from the server.
Service API HTTP Method: DELETE Header: { "Authorization":"Bearer <TOKEN>", } Request: Path: /sessions/logout/ Body: None Response: (Success, 201) Body: None Response: (Failure, 500) Body: `{ "status":"", "title":"", "message":"", }
func (Sessions) LogoutWithJSON ¶
LogoutWithJSON handles receiving requests to end a user session from the server.
Service API HTTP Method: DELETE Request: Path: /sessions/logout/ Body: { "user_id": "", "token": "" } Response: (Success, 201) Body: None Response: (Failure, 500) Body: `{ "status":"", "title":"", "message":"", }
type Users ¶
Users exposes a central handle for which requests are served to all requests.
func (Users) Create ¶
Create handles receiving requests to create a user from the server.
Service API HTTP Method: POST Request: Path: /users/ Body: { "password":"", "email":"", } Response: (Success, 200) Body: { "public_id":"", "email":"", "profile":"optional", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) Delete ¶
Delete handles receiving requests to removes a user from the server.
Service API HTTP Method: DELETE Request: Path: /users/:user_id Body: None Response: (Success, 201) Body: None Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) Get ¶
Get handles receiving requests to get a users from the db.
Service API HTTP Method: GET Request: Path: /admin/users/:user_id Body: None Response: (Success, 200) Body: { "public_id":"", "private_id":"", "hash":"", "email":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) GetAll ¶
GetAll handles receiving requests to get all users from the db.
Service API HTTP Method: GET Request: Path: /users Path: /users/:responser_per_page/:page Body: None Response: (Success, 200) Body: { page: 1, total: 100, responsePerPage: 24, records: [{ "public_id":"", "private_id":"", "hash":"", "email":"", }] } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) GetLimited ¶
GetLimited handles receiving requests to get a user from the db but returns a limited view of the user data. This is suited for when needing to respond to requests from non-authorized requests or wishing to exclude security based fields (hash, private_id) from the response.
Service API HTTP Method: GET Request: Path: /users/:user_id Body: None Response: (Success, 200) Body: { "public_id":"", "email":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) Update ¶
Update handles receiving requests to update a user identified by it's public_id.
Service API HTTP Method: PUT Request: Path: /users/:user_id Body: None Response: (Success, 201) Body: { "public_id":"", "email":"", } Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }
func (Users) UpdatePassword ¶
UpdatePassword handles receiving requests to update a user identified by it's public_id.
Service API HTTP Method: PUT Request: Path: /users/password/:user_id Body: None { "public_id":"", "password":"", "password_confirmation":"", } Response: (Success, 201) Body: None Response: (Failure, 500) Body: { "status":"", "title":"", "message":"", }