Summer Fun Microframework

Summer Fun is a functional microframework for Java.

                            
                                import summer.fun.config.Configuration;
                            import summer.fun.config.ConfigurationBuilder;
                            import summer.fun.SummerFun;

                            public class SampleApp {
                                public static void main(String[] args) {
                                    Configuration config = ConfigurationBuilder.newBuilder()
                                        .withContextPath("/api")
                                        .build();

                                    SummerFun app = new SummerFun()
                                        .withConfiguration(config);

                                    // http://localhost:7000/api/users
                                    app.get("/users", (request, response) -> {
                                        List<User> users = findUsers();
                                        response.json().send(users);
                                    });

                                    app.run(() -> {
                                        System.out.println("Application is running on port " + config.getPort());
                                        System.out.println("Press any key to stop the server...");
                                    });
                                }

                                public static List<User> findUsers() {
                                    List<User> users = new ArrayList<>();

                                    User user1 = new User();
                                    user1.setId(1);
                                    user1.setLastName("Rizal");
                                    user1.setFirstName("Jose");
                                    users.add(user1);

                                    User user2 = new User();
                                    user2.setId(2);
                                    user2.setLastName("Bonifacio");
                                    user2.setFirstName("Andres");
                                    users.add(user2);

                                    User user3 = new User();
                                    user3.setId(3);
                                    user3.setLastName("Mabini");
                                    user3.setFirstName("Apolinario");
                                    users.add(user3);

                                    return users;
                                }
                            }

                            class User {
                                private int id;
                                private String lastName;
                                private String firstName;

                                public int getId() {
                                    return id;
                                }

                                public void setId(int id) {
                                    this.id = id;
                                }

                                public String getLastName() {
                                    return lastName;
                                }

                                public void setLastName(String lastName) {
                                    this.lastName = lastName;
                                }

                                public String getFirstName() {
                                    return firstName;
                                }

                                public void setFirstName(String firstName) {
                                    this.firstName = firstName;
                                }
                            }
                            
                        
Features

  • Inspired by microframeworks from different programming languages - Slim Framework, ExpressJS, Spark.
  • Uses Grizzly HTTP Server framework, a component of Grizzly NIO framework which has been designed to help developers to take advantage of the Java™ NIO API.
  • Lightweight
Get Started

Clone the repository and install using Maven:

                                    
                                        git clone https://gitlab.com/summer-fun/summer-fun
                                        cd summer-fun
                                        mvn install
                                    
                                

Clone, build, and run sample application:

                                    
                                        git clone https://gitlab.com/summer-fun/summer-fun-sample
                                        cd summer-fun-sample
                                        mvn package
                                        java -jar ./target/summer-fun-sample-1.0.0.jar
                                    
                                

Open browser:

  • http://localhost:7000/app
  • http://localhost:7000/app/users
  • http://localhost:7000/app/users/1
  • http://localhost:7000/app/users/2
  • http://localhost:7000/app/users/3
  • http://localhost:7000/app/users/10
  • http://localhost:7000/app/user-list
License

Summer Fun, a Java microframework.
Copyright (C) 2018 Julian V. Jupiter

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.