New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Banned APIs #6

Merged
merged 1 commit into from Sep 7, 2018

Conversation

Projects
None yet
3 participants
@terry-xiaoyu
Contributor

terry-xiaoyu commented Sep 7, 2018

Inspired by Plug, it uses a pipeline to handle a sequence of
functions verifying and formatting the params.

Add Banned APIs
Inspired by `Plug`, it uses a pipeline to handle a sequence of
 functions verifying and formatting the params.

@terry-xiaoyu terry-xiaoyu requested review from emqplus, turtleDeng and wiviwiv Sep 7, 2018

@terry-xiaoyu

This comment has been minimized.

Contributor

terry-xiaoyu commented Sep 7, 2018

  • List Banned:

    Request:

    GET  `/banned` (pagination)
    

    Response:

    => 200 OK
    
    {
        "items": [{
            "who": "shawn",    // the client to be banned
            "as": "client_id"  // the type of "who", can be "client_id", "username", or "ip_address"
            "reason": "xxx",
            "desc": "xxxx", 
            "until": 1536146587 // timestamp in seconds
        }],
        "meta": {"count":0,"limit":10000,"page":1}
    }
    
  • Add Banned:

    Request:

    POST  `/banned`
    {
        "who": "shawn",    // the client to be banned
        "as": "client_id"  // the type of "who", can be "client_id", "username", or "ip_address"
        "reason": "xxx",
        "desc": "xxxx", 
        "until": 1536146587 // timestamp in seconds
    }
    

    Response:

    => 201 Created
    
    {
        "who": "shawn",    // the client to be banned
        "as": "client_id",
        "reason": "xxx",
        "desc": "xxxx", 
        "until": 1536146587 // timestamp in seconds
    }
    
    => 422 BadRequest
    {
        "message": "'as' can only be one of client_id, username or ip_address",
        "errorCode": 108
    }
    
  • Delete Banned:

    Request:

    DELETE  `/banned/shawn?as=username`
    

    Response:

    => 200 OK
    
    ok
    
    

@turtleDeng turtleDeng merged commit 63d6148 into emqx30 Sep 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment