• restheart 基本使用


    restheart 是一个方便基于mongodb的restapi 开发框架

    参考项目 https://github.com/rongfengliang/restheart-docker-compose

    docker-compose 环境运行

    • docker-compose yaml 文件
    version: '3'
    networks:
       backend:
    services:
       restheart:
          image: softinstigate/restheart
          container_name: restheart
          depends_on:
             - mongodb
          networks:
             - backend
          ports:
             - "8080:8080"
          # volumes:
          # - ./etc:/opt/restheart/etc:ro
    
       mongodb:
          image: mongo:3.6
          container_name: restheart-mongo
          environment:
                MONGO_INITDB_ROOT_USERNAME: restheart
                MONGO_INITDB_ROOT_PASSWORD: R3ste4rt!
          command: --bind_ip_all --auth
          volumes:
             - ./data:/data/db
          networks:
             - backend
          ports:
            - "27017:27017"
    
    restheart配置:
    
    • 启动
    docker-compose up -d
    • 访问
    http://localhost:8080/browser/#/?hal=f

    基本操作

    • 创建数据库

      使用httpie 工具

    http -a 'admin:changeit' PUT localhost:8080/db desc='this is my first db created with restheart'
    
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: u5pxfezxze7mau2999yhjk60p4j1vnq864m5m05a711ool4x9
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T05:58:59.239Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 05:43:59 GMT
    Etag: 5b8e1b9f5c404500080d1634
    Keep-Alive: timeout=38
    X-Powered-By: restheart.org
    
    • 创建集合
    http -a 'admin:changeit' PUT localhost:8080/db/coll desc='my first collection created with restheart'
    
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: 148lrvqkmnl6k2mvxnoilpbv5p167xc3w7fqavbubvnsfekj3t
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T06:41:59.905Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 06:26:59 GMT
    Etag: 5b8e25b35c404500080d1636
    Keep-Alive: timeout=38
    X-Powered-By: restheart.org
    
    • 添加集合
    http -a 'admin:changeit' POST localhost:8080/db/coll name='RESTHeart' rating='cool'
    HTTP/1.1 201 Created
    Access-Control-Allow-Credentials: true
    Access-Control-Allow-Origin: *
    Access-Control-Expose-Headers: Location, ETag, Auth-Token, Auth-Token-Valid-Until, Auth-Token-Location, X-Powered-By
    Auth-Token: 148lrvqkmnl6k2mvxnoilpbv5p167xc3w7fqavbubvnsfekj3t
    Auth-Token-Location: /_authtokens/admin
    Auth-Token-Valid-Until: 2018-09-04T06:43:40.028Z
    Content-Length: 0
    Content-Type: application/json
    Date: Tue, 04 Sep 2018 06:28:40 GMT
    Etag: 5b8e26185c404500080d1637
    Keep-Alive: timeout=38
    Location: http://localhost:8080/db/coll/5b8e2618c5a8c63d6b2839cd
    X-Powered-By: restheart.org
    
    • 获取集合数据
    http -a 'admin:changeit' GET localhost:8080/db/coll

    参考资料

    https://restheart.org/learn/tutorial/
    https://github.com/rongfengliang/restheart-docker-compose

  • 相关阅读:
    P1026 统计单词个数
    常见的DP优化类型
    中国空气质量在线监測分析平台
    Linux Kernel系列一:开篇和Kernel启动概要
    Android入门第八篇之GridView(九宫图)
    eclipse+webservice开发实例
    【java读书笔记】——java开篇宏观把控 + HelloWorld
    选择排序
    The encryption certificate of the relying party trust identified by thumbprint is not valid
    【传递正能量】2014年感动我的十大微视频
  • 原文地址:https://www.cnblogs.com/rongfengliang/p/9584470.html
Copyright © 2020-2023  润新知