Skip to content
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 new dsl to describe api design #23

Closed
alimy opened this issue Dec 18, 2020 · 9 comments
Closed

add new dsl to describe api design #23

alimy opened this issue Dec 18, 2020 · 9 comments
Labels
Milestone

Comments

@alimy
Copy link
Owner

alimy commented Dec 18, 2020

package v2

// Site service
service Site {
        _             Chain
	v2            Group
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}
@alimy alimy added the feature label Dec 18, 2020
@alimy
Copy link
Owner Author

alimy commented Dec 18, 2020

package v1

// Site v1 service
Site[v1] {
        _             Chain
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}

package v2

// Site v2 service
Site[v2] {
        _             Chain
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}

@alimy
Copy link
Owner Author

alimy commented Dec 18, 2020

package v1

// Site v1 service
Site v1 {
        _             Chain
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}
package v2

// Site v2 service
Site v2 {
        _             Chain
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}

@alimy
Copy link
Owner Author

alimy commented Dec 18, 2020

package v1

// Site v1 service
service Site(v1 Group, _ Chain) {
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}

package v2

// Site v2 service
service Site(v2 Group, _ Chain) {
	Index         Get   `/index/`
	Articles      Get   `/articles/:category/`
	Category      Get   `/category/`
        PostArticle   Post  `/articles/:category/`
}

@alimy
Copy link
Owner Author

alimy commented Dec 22, 2020

package v1

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}

// Site v1 service
service Site(v1) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(ArticleReq) {
                      contentType: application/json
               }

               Response(ArticleRes) {
                     contentType: application/json
               }
        }
}

package v2/core

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}
package v2

import v2/core

// Site v2 service
service Site(v2 Group, _ Chain) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(core.ArticleReq) {
                      contentType: application/json
               }

               Response(core.ArticleRes) {
                     contentType: application/json
               }
        }
}

@alimy
Copy link
Owner Author

alimy commented Dec 22, 2020

package v1

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}

// Site v1 service
service Site(v1) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(body: ArticleReq) {
                      contentType: application/json
               }

               Response(body: ArticleRes, contentType: application/json)
        }
}

package v2/core

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}
package v2

import v2/core

// Site v2 service
service Site(group: v2, chain: _) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(body: core.ArticleReq, contentType: application/json)

               Response(body: core.ArticleRes) {
                     contentType: application/json
               }
        }
}

@alimy
Copy link
Owner Author

alimy commented Dec 22, 2020

package v1

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}

// Site v1 service
service Site(v1) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(body: ArticleReq) {
                      content-type: application/json,
               }

               Response(body: ArticleRes) {
                      content-type: application/json,
               }
        }
}

package v2/core

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}
package v2

import v2/core

// Site v2 service
service Site(group: v2, chain: _) {
	Index         Get(/index/)
	Articles      Get(/articles/:category/)
	Category      Get(/category/)

        PostArticle   Post(/articles/:category/) {
               Request(body: core.ArticleReq) {
                      content-type: application/json,
               }

               Response(body: core.ArticleRes) {
                     content-type: application/json,
               }
        }
}

@alimy
Copy link
Owner Author

alimy commented Dec 22, 2020

package v1

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}

// Site v1 service
service Site(group: v1) {
	Index         get(/index/)
	Articles      get(/articles/:category/)
	Category      get(/category/)

        PostArticle   post(/articles/:category/) {
               request(body: ArticleReq) {
                      Content-Type: application/json,
               }

               response(body: ArticleRes) {
                      Content-Type: application/json,
               }
        }
}
package v2/core

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code int
     Msg   string
     PostId string    `json:"postid"`
}
 
message IndexHead {
     LastTime string  `head:"x-last-time"`
}
package v2

import v2/core

// Site v2 service
service Site(group: v2, chain: _) {
	Index         get(/index/) {
                request(head: core.IndexHead)
        }

	Articles      get(/articles/:category/)
	Category      get(/category/)

        PostArticle   post(/articles/:category/) {
               request(body: core.ArticleReq) {
                      Content-Type: application/json,
               }

               response(body: core.ArticleRes) {
                     Content-Type: application/json,
               }
        }
}

@alimy
Copy link
Owner Author

alimy commented Dec 25, 2020

%> cat site_v1.m2

//mir:syntax v0.1-alpha.1

package v1

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
    Code   int       `json:"code"`
    Msg    string    `json:"msg"`
    PostId string    `json:"postid"`
}

// Site v1 service
service Site(group: v1) {
    Index()                                    `get:"/index/"`
    Articles()                                 `get:"/articles/:category/"`
    Category()                                 `get:"/category/"`
    PostArticle(article ArticleReq) ArticleRes `post:"/articles/:category/"`
}
%> cat common.m2

//mir:syntax v0.1-alpha.1

package core

message ArticleReq {
     Content string  `json:"content"`
}

message ArticleRes {
     Code   int      `json:"code"`
     Msg    string   `json:"msg"`
     PostId string   `json:"postid"`
}
 
message IndexHead {
     LastTime string `param:"lastTime"`
}
%> cat site_v2.m2

//mir:syntax v0.1-alpha.1

package v2

import core

// Site v2 service
service Site(group: v2, chain: _) {
    Index(param core.indexParam)                         `get:"/index"`
    Articles()                                           `get, post:"/articles/:category/"`
    Category()                                           `get:"/category/"`
    PostArticle(article core.ArticleReq) core.ArticleRes `post:"/articles/:category/"`
}

@alimy alimy added this to the next milestone Nov 8, 2022
@alimy alimy assigned alimy and unassigned alimy Nov 8, 2022
@alimy
Copy link
Owner Author

alimy commented Dec 31, 2023

确定使用 Thrift IDL 来定义RESTful接口。详情参看 #43.

@alimy alimy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant