Coder Social home page Coder Social logo

bjansen / gyokuro Goto Github PK

View Code? Open in Web Editor NEW
27.0 27.0 3.0 638 KB

Web framework written in Ceylon ๐Ÿ˜

Home Page: http://www.gyokuro.net

License: MIT License

CSS 1.82% HTML 2.52% JavaScript 0.90% Ceylon 88.73% Shell 2.42% Batchfile 3.61%
ceylon framework rest web-framework

gyokuro's People

Contributors

bjansen avatar sadmac7000 avatar xkr47 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

gyokuro's Issues

Add support for path parameters

Though not a standard per se, having URIs with required elements as path parameters could allow users to create cleaner APIs.

route("/home")
controller object userController {
    route("/{group}/users/{id}/scores")
    shared void showUserScores(String group, Integer id) {}
}

Support having default routes without a trailing slash in annotated controllers

If one defines a partial path on the controller, the default route ends with a trailing slash:

route("/users")
controller class UserController {

    route("") //and route("/") both map to /users/
    shared void listUsers() {}
}

This might not conform to established conventions. Might an empty route, route("") or route, be treated as the default route and separate from route("/")?

route("/users")
controller class UserController {

    route //maps to /users
    shared void listUsers() {}

    route("/") //maps to /users/
    shared void somethingElse() {}
}

Errors when applying a method to a route

I get multiple errors using 0.2-dev and Ceylon 1.2.2 when applying a method to a route, including: Illegal annotation argument... and Type functions are not supported on the JVM.

screen shot 2016-08-28 at 7 22 32 pm

Generate REST API documentation from the code

Generate REST API documentation from the code, something similar to Swagger JAX-RS extension, but without all their annotations (they have just too many), which is possible in Ceylon, thanks to its great metaprogramming, reified generics and its support of named, optional and default arguments).

It could be another module that inspects the app and generates an HTML report. Something that could be done in a continuous integration server, for example.

Support MIME types

Add support according to the specification: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

Check out the JAX-RS way of doing it: https://docs.jboss.org/resteasy/docs/1.0.2.GA/userguide/html/JAX-RS_Content_Negotiation.html

Guava has a MediaType class that helps a little bit with matching accept headers and routes: http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/net/MediaType.html

You can copy the MIMEParser from my project if you want (I also copied it, but gave credit to the author - Spark also copied but did not even acknowledge): https://github.com/renatoathaydes/easy-jetty/blob/master/easy-jetty-core/src/main/java/com/athaydes/easyjetty/external/MIMEParse.java

object controllers

I think object declarations should be able to be controllers as well as classes:

route("/foo")
shared controller object foo
{
    route("/bar")
    shared controller object bar
    {
        route("/baz")
        shared String baz()
        {
            return("Hello, World!");
        }
    }
}

Have users import their template library instead of providing it

Providing an implementation of TemplateRenderer is helpful, but importing the template library might harm flexibility. Mustache, for example, is at version 0.9.3 for Java 8 and 0.8.18 for Java 7. A user might want the option to choose depending on requirements.

Custom error handlers/pages

The current behavior is to write something like

400 โ€” Bad request

It would be nice to customize that output, either by allowing custom error handlers, or custom error pages.

Filters

Something similar to:

void myFilter(Request req, Response resp, Anything(Request, Response) next) {
    doStuffBefore();
    next(req, resp);
    doStuffAfter();
}

value app = Application {
   ...
   filters = [myFilter]
};

An extra filter will automatically be added at the end of the chain to call the handler.

(de)serialization

The current jsonSerializer was good enough for a PoC, but I think it'd be better if we provided an extension point like we did for template engines:

shared interface Serializer {
    shared formal String serialize(Object o);
    shared formal Type deserialize<Type>(String serialized);
    shared formal [String+] contentTypes;
}

And then provide implementations based on:

The correct serializer would be picked based on the request's content type.

Also provide a deserializer that reads the body of a request and creates an object that can be passed to handlers:

void handler(serialized MyDomainObject obj) { }

serialized indicates that a deserializer should be used to create the instance. The correct deserializer would be picked based on the request's content type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.