mmontone / cl-rest-server

Serve REST APIs from Common Lisp
http://mmontone.github.io/cl-rest-server/cl-rest-server/
MIT License
66 stars 9 forks source link

Some doc is out dated #4

Open ailisp opened 7 years ago

ailisp commented 7 years ago

I noticed the implement-resource-operation is now different as doc said. For example

(implement-resource-operation get-user (id &key expand)
   (serialize (find-user id) :expand expand))

should change to

(implement-resource-operation apt-test get-user (id &key expand)
   (serialize (find-user id) :expand expand))
mmontone commented 7 years ago

Yes. Sorry. I'll try to update the docs when I find time. The library has gone through some changes.

I was not aware there were users of the library, apart from me. :)

mmontone commented 7 years ago

I guess your best bet is to look at test code for now until I get to update the docs.

ailisp commented 7 years ago

Thanks! You are so kind to say there are no users, I think rest-server provide the most declarative and powerful REST api define tools. I have read the code and tests, it now works well.

2017年2月27日 下午8:03,"Mariano Montone" notifications@github.com写道:

I guess your best bet is to look at test code for now until I get to update the docs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mmontone/cl-rest-server/issues/4#issuecomment-282908444, or mute the thread https://github.com/notifications/unsubscribe-auth/AMpSiAPukfiep54JKa5pxaGMDSRD4ogcks5rg3JcgaJpZM4MNxB9 .

mmontone commented 7 years ago

I wish it worked better!

Some of the things I tried didn't work out, like having transparent JSON and XML serialization and de-serialization. It works for JSON only for now.

Also the dispatching system is a bit messy. Could be less messy and also more complete, webmachine like.

I'm not kind when I say there are no users, I'm really not aware of any users :)

Cheers

On 28/02/17 09:51, Bo Yao wrote:

Thanks! You are so kind to say there are no users, I think rest-server provide the most declarative and powerful REST api define tools. I have read the code and tests, it now works well.

2017年2月27日 下午8:03,"Mariano Montone" notifications@github.com写道:

I guess your best bet is to look at test code for now until I get to update the docs.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub

https://github.com/mmontone/cl-rest-server/issues/4#issuecomment-282908444, or mute the thread

https://github.com/notifications/unsubscribe-auth/AMpSiAPukfiep54JKa5pxaGMDSRD4ogcks5rg3JcgaJpZM4MNxB9 .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mmontone/cl-rest-server/issues/4#issuecomment-283030872, or mute the thread https://github.com/notifications/unsubscribe-auth/AAanjniy1l9U04A4GMS2hCtSetXGeltDks5rhBhTgaJpZM4MNxB9.

ailisp commented 7 years ago

For dispatching, are you mean this And if when define api:

(define-api api-test
    (:title "Api test"
            :documentation "This is an api test")
  (parameters (:produces (:json)
                         :consumes (:json)
                         :documentation "Parameters test"
                         :path "/parameters")
              (parameters (:produces (:json)
                                     :consumes (:json)
                                     :documentation "Parameters test"
                                     :path "/parameters")
                          (&optional (boolean :boolean nil "A boolean parameter")
                                     (integer :integer nil "An integer parameter")
                                     (string :string nil "A string parameter")
                                     (list :list nil "A list parameter")))) ...)

If the inside parameters can derive options from the outside parameters that not provided it will be more convenient. Or we may use:

(define-api api-test
    (:title "Api test"
            :documentation "This is an api test")
  (parameters (:produces (:json)
                         :consumes (:json)
                         :documentation "Parameters test"
                         :path "/parameters")
              (:default
                          (&optional (boolean :boolean nil "A boolean parameter")
                                     (integer :integer nil "An integer parameter")
                                     (string :string nil "A string parameter")
                                     (list :list nil "A list parameter")))) ...)

to indicate the same. This only my personal preference, and not as important as XML serialization and dispatching. If you think these change (in define-api) is reasonable, I can send you a pull request ;)

mmontone commented 7 years ago

No, I mean this: https://github.com/mmontone/cl-rest-server/blob/master/src/api.lisp#L171

I'm not happy with that code.

Also, it doesn't implement this: https://raw.githubusercontent.com/webmachine/webmachine/develop/docs/http-headers-status-v3.png

Like other frameworks out there.

https://github.com/inhabitedtype/ocaml-webmachine

ailisp commented 7 years ago

It's quite a lot error handling to do, wish cl-rest-server can be mature enough in the future

mmontone commented 7 years ago

The implementation technique for that is "parsing" that diagram in some way (you could have a declarative spec of that diagram) and generate the conditional code that does the dispatching. Sounds like fun.

ailisp commented 7 years ago

Sounds like something I learned from Software Engineering course of auto generate Java program from UML. The program generated is 90% accurate, but that's enough. It's cool if you implement one for Common Lisp.